only start editing if input is empty

This commit is contained in:
ouwou
2023-07-15 16:03:33 -04:00
parent f941ad1bef
commit 03e617a146
3 changed files with 7 additions and 1 deletions

View File

@@ -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();

View File

@@ -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();

View File

@@ -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);