summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2023-07-15 16:03:33 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2023-07-15 16:03:33 -0400
commit03e617a146666ad95f8cf9ff144f1cec4ae4c6cd (patch)
tree8ba7c176d7cd16db38bfd20df4587712fd58f1a5 /src
parentf941ad1befc0049bb2c4be08cf76df0c09dc1016 (diff)
downloadabaddon-portaudio-03e617a146666ad95f8cf9ff144f1cec4ae4c6cd.tar.gz
abaddon-portaudio-03e617a146666ad95f8cf9ff144f1cec4ae4c6cd.zip
only start editing if input is empty
Diffstat (limited to 'src')
-rw-r--r--src/components/chatinput.cpp4
-rw-r--r--src/components/chatinput.hpp2
-rw-r--r--src/components/chatwindow.cpp2
3 files changed, 7 insertions, 1 deletions
diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp
index c88de49..f53c6fe 100644
--- a/src/components/chatinput.cpp
+++ b/src/components/chatinput.cpp
@@ -579,6 +579,10 @@ void ChatInput::StopEditing() {
m_input.Get().get_style_context()->remove_class("editing");
}
+bool ChatInput::IsEmpty() {
+ return GetBuffer()->get_char_count() == 0;
+}
+
bool ChatInput::AddFileAsImageAttachment(const Glib::RefPtr<Gio::File> &file) {
try {
const auto read_stream = file->read();
diff --git a/src/components/chatinput.hpp b/src/components/chatinput.hpp
index c98d935..393a9aa 100644
--- a/src/components/chatinput.hpp
+++ b/src/components/chatinput.hpp
@@ -143,6 +143,8 @@ public:
void StartEditing(const Message &message);
void StopEditing();
+ bool IsEmpty();
+
private:
bool AddFileAsImageAttachment(const Glib::RefPtr<Gio::File> &file);
bool CanAttachFiles();
diff --git a/src/components/chatwindow.cpp b/src/components/chatwindow.cpp
index dcff656..17f5601 100644
--- a/src/components/chatwindow.cpp
+++ b/src/components/chatwindow.cpp
@@ -287,7 +287,7 @@ bool ChatWindow::OnInputSubmit(ChatSubmitParams data) {
bool ChatWindow::ProcessKeyEvent(GdkEventKey *e) {
if (e->type != GDK_KEY_PRESS) return false;
- if (e->keyval == GDK_KEY_Up) {
+ if (e->keyval == GDK_KEY_Up && !(e->state & GDK_SHIFT_MASK) && m_input->IsEmpty()) {
const auto edit_id = m_chat->GetLastSentMessage();
if (edit_id.has_value()) {
StartEditing(*edit_id);