From add48af094ec9111727862d3f2ee1916474a2471 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sat, 15 Jul 2023 17:18:04 -0400 Subject: [PATCH] restrict attachments when editing --- src/components/chatinput.cpp | 6 +++++- src/components/chatinput.hpp | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp index f53c6fe0..11333027 100644 --- a/src/components/chatinput.cpp +++ b/src/components/chatinput.cpp @@ -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"); } @@ -595,7 +599,7 @@ bool ChatInput::AddFileAsImageAttachment(const Glib::RefPtr &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() { diff --git a/src/components/chatinput.hpp b/src/components/chatinput.hpp index 393a9aaa..a3c97424 100644 --- a/src/components/chatinput.hpp +++ b/src/components/chatinput.hpp @@ -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; using type_signal_escape = sigc::signal;