aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp78
1 files changed, 53 insertions, 25 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index f009cdd..1caf831 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3073,6 +3073,28 @@ namespace QuickMedia {
return result_items;
}
+ static bool is_state_message_type(const Message *message) {
+ if(!message)
+ return true;
+
+ switch(message->type) {
+ case MessageType::TEXT:
+ return false;
+ case MessageType::IMAGE:
+ return false;
+ case MessageType::VIDEO:
+ return false;
+ case MessageType::AUDIO:
+ return false;
+ case MessageType::FILE:
+ return false;
+ default:
+ return true;
+ }
+
+ return true;
+ }
+
struct PinnedEventData {
std::string event_id;
FetchStatus status = FetchStatus::NONE;
@@ -3730,10 +3752,12 @@ namespace QuickMedia {
frame_skip_text_entry = true;
std::shared_ptr<BodyItem> selected = tabs[selected_tab].body->get_selected_shared();
if(selected) {
- chat_state = ChatState::REPLYING;
- currently_operating_on_item = selected;
- chat_input.set_editable(true);
- replying_to_text.setString("Replying to:");
+ if(!is_state_message_type(static_cast<Message*>(selected->userdata))) {
+ chat_state = ChatState::REPLYING;
+ currently_operating_on_item = selected;
+ chat_input.set_editable(true);
+ replying_to_text.setString("Replying to:");
+ }
} else {
// TODO: Show inline notification
show_notification("QuickMedia", "No message selected for replying");
@@ -3744,19 +3768,21 @@ namespace QuickMedia {
frame_skip_text_entry = true;
std::shared_ptr<BodyItem> selected = tabs[selected_tab].body->get_selected_shared();
if(selected) {
- if(!selected->url.empty()) { // cant edit messages that are image/video posts
- // TODO: Show inline notification
- show_notification("QuickMedia", "You can only edit messages with no file attached to it");
- } else if(!matrix->was_message_posted_by_me(selected->userdata)) {
- // TODO: Show inline notification
- show_notification("QuickMedia", "You can't edit a message that was posted by somebody else");
- } else {
- chat_state = ChatState::EDITING;
- currently_operating_on_item = selected;
- chat_input.set_editable(true);
- chat_input.set_text(selected->get_description()); // TODO: Description? it may change in the future, in which case this should be edited
- chat_input.move_caret_to_end();
- replying_to_text.setString("Editing message:");
+ if(!is_state_message_type(static_cast<Message*>(selected->userdata))) {
+ if(!selected->url.empty()) { // cant edit messages that are image/video posts
+ // TODO: Show inline notification
+ show_notification("QuickMedia", "You can only edit messages with no file attached to it");
+ } else if(!matrix->was_message_posted_by_me(selected->userdata)) {
+ // TODO: Show inline notification
+ show_notification("QuickMedia", "You can't edit a message that was posted by somebody else");
+ } else {
+ chat_state = ChatState::EDITING;
+ currently_operating_on_item = selected;
+ chat_input.set_editable(true);
+ chat_input.set_text(selected->get_description()); // TODO: Description? it may change in the future, in which case this should be edited
+ chat_input.move_caret_to_end();
+ replying_to_text.setString("Editing message:");
+ }
}
} else {
// TODO: Show inline notification
@@ -3768,14 +3794,16 @@ namespace QuickMedia {
frame_skip_text_entry = true;
BodyItem *selected = tabs[selected_tab].body->get_selected();
if(selected) {
- void *selected_message = selected->userdata;
- post_task_queue.push([this, &current_room, selected_message]() {
- std::string err_msg;
- if(matrix->delete_message(current_room, selected_message, err_msg) != PluginResult::OK) {
- // TODO: Show inline notification
- fprintf(stderr, "Failed to delete message, reason: %s\n", err_msg.c_str());
- }
- });
+ if(!is_state_message_type(static_cast<Message*>(selected->userdata))) {
+ void *selected_message = selected->userdata;
+ post_task_queue.push([this, &current_room, selected_message]() {
+ std::string err_msg;
+ if(matrix->delete_message(current_room, selected_message, err_msg) != PluginResult::OK) {
+ // TODO: Show inline notification
+ fprintf(stderr, "Failed to delete message, reason: %s\n", err_msg.c_str());
+ }
+ });
+ }
} else {
// TODO: Show inline notification
show_notification("QuickMedia", "No message selected for deletion");