Skip to content

Commit

Permalink
restrict attachments when editing
Browse files Browse the repository at this point in the history
  • Loading branch information
ouwou committed Jul 15, 2023
1 parent 03e617a commit add48af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/chatinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,16 @@ void ChatInput::StopReplying() {
}

void ChatInput::StartEditing(const Message &message) {
m_is_editing = true;
m_input.Get().grab_focus();
m_input.Get().get_style_context()->add_class("editing");
GetBuffer()->set_text(message.Content);
m_attachments.Clear();
m_attachments_revealer.set_reveal_child(false);
}

void ChatInput::StopEditing() {
m_is_editing = false;
m_input.Get().get_style_context()->remove_class("editing");
}

Expand All @@ -595,7 +599,7 @@ bool ChatInput::AddFileAsImageAttachment(const Glib::RefPtr<Gio::File> &file) {
}

bool ChatInput::CanAttachFiles() {
return Abaddon::Get().GetDiscordClient().HasSelfChannelPermission(m_active_channel, Permission::ATTACH_FILES | Permission::SEND_MESSAGES);
return !m_is_editing && Abaddon::Get().GetDiscordClient().HasSelfChannelPermission(m_active_channel, Permission::ATTACH_FILES | Permission::SEND_MESSAGES);
}

ChatInput::type_signal_submit ChatInput::signal_submit() {
Expand Down
2 changes: 2 additions & 0 deletions src/components/chatinput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ class ChatInput : public Gtk::Box {

Snowflake m_active_channel;

bool m_is_editing = false;

public:
using type_signal_submit = sigc::signal<bool, ChatSubmitParams>;
using type_signal_escape = sigc::signal<void>;
Expand Down

0 comments on commit add48af

Please sign in to comment.