aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-26 23:19:35 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-26 23:19:35 +0100
commit60e48e51cff48bc17959267a985e1e2431f77cea (patch)
tree0f6b056f04a31b88660ab78521aae312d9e38a7d /src/plugins
parent36db818f77b8a69f6e585ddd1edb4b9cc6376596 (diff)
Better system messages for /id and /help
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 2689904..c69a6df 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -187,7 +187,10 @@ namespace QuickMedia {
int64_t last_new_message_timestamp = last_message_timestamp;
size_t num_new_messages = 0;
for(auto it = new_messages.begin(); it != new_messages.end(); ++it) {
- if(message_by_event_id.find((*it)->event_id) == message_by_event_id.end()) {
+ if((*it)->event_id.empty()) {
+ messages.insert(messages.begin(), std::move(*it));
+ ++num_new_messages;
+ } else if(message_by_event_id.find((*it)->event_id) == message_by_event_id.end()) {
if(message_is_timeline((*it).get()))
last_new_message_timestamp = std::max(last_new_message_timestamp, (*it)->timestamp);
message_by_event_id.insert(std::make_pair((*it)->event_id, *it));
@@ -204,7 +207,10 @@ namespace QuickMedia {
int64_t last_new_message_timestamp = last_message_timestamp;
size_t num_new_messages = 0;
for(auto it = new_messages.begin(); it != new_messages.end(); ++it) {
- if(message_by_event_id.find((*it)->event_id) == message_by_event_id.end()) {
+ if((*it)->event_id.empty()) {
+ messages.push_back(std::move(*it));
+ ++num_new_messages;
+ } else if(message_by_event_id.find((*it)->event_id) == message_by_event_id.end()) {
if(message_is_timeline((*it).get()))
last_new_message_timestamp = std::max(last_new_message_timestamp, (*it)->timestamp);
message_by_event_id.insert(std::make_pair((*it)->event_id, *it));
@@ -2065,6 +2071,15 @@ namespace QuickMedia {
return message->type >= MessageType::TEXT && message->type <= MessageType::FILE;
}
+ void Matrix::append_system_message(RoomData *room_data, std::shared_ptr<Message> message) {
+ Messages new_messages;
+ new_messages.push_back(std::move(message));
+ room_data->append_messages(new_messages);
+ ui_thread_tasks.push([this, room_data, new_messages{std::move(new_messages)}]{
+ delegate->room_add_new_messages(room_data, new_messages, false, false, MessageDirection::AFTER);
+ });
+ }
+
size_t Matrix::events_add_messages(const rapidjson::Value &events_json, RoomData *room_data, MessageDirection message_dir, bool has_unread_notifications) {
if(!events_json.IsArray())
return 0;