From 7b91566f303b4afd2deeb6c893ee805e4d62fdaf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 16 Dec 2023 16:07:13 +0100 Subject: Matrix: keep chat message when pressing esc or going back to previous page. Press ctrl+d to remove text instead (in input mode) --- plugins/Matrix.hpp | 1 + src/QuickMedia.cpp | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index 68081d8..de66481 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -238,6 +238,7 @@ namespace QuickMedia { int notification_power_level = 50; size_t index = 0; std::atomic gpg_decrypt_message_id = 0; + std::string chat_message; private: std::mutex user_mutex; std::recursive_mutex room_mutex; diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 99e68df..7b052f4 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -6011,6 +6011,7 @@ namespace QuickMedia { Entry chat_input("Press i to start writing a message...", &rounded_rectangle_shader); chat_input.set_editable(false); chat_input.set_padding_scale(1.5f); + chat_input.set_text(current_room->chat_message); struct ProvisionalMessage { std::shared_ptr body_item; @@ -7438,7 +7439,6 @@ namespace QuickMedia { mention.hide(); } else { chat_input.set_editable(false); - chat_input.set_text(""); chat_state = ChatState::NAVIGATING; currently_operating_on_item = nullptr; if(typing && current_room) { @@ -7512,11 +7512,6 @@ namespace QuickMedia { if(chat_state == ChatState::REPLYING) chat_input.set_editable(true); } else { - mention.hide(); - chat_input.set_editable(false); - chat_input.set_text(""); - chat_state = ChatState::NAVIGATING; - currently_operating_on_item = nullptr; if(typing && current_room) { fprintf(stderr, "Stopped typing\n"); typing = false; @@ -7968,6 +7963,7 @@ namespace QuickMedia { } chat_page_end: + current_room->chat_message = chat_input.get_text(); matrix_chat_page->set_current_room(nullptr, nullptr, nullptr); fetch_messages_future.cancel(); cleanup_tasks(); -- cgit v1.2.3