aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-02-09 10:38:39 +0100
committerdec05eba <dec05eba@protonmail.com>2021-02-09 10:38:39 +0100
commit07c8a8f1d469672be5196570608cf0d14b4d5b21 (patch)
tree56f42cec6c6d4a121cb5edfa9dd7a3809617ce3c /src/QuickMedia.cpp
parent34fd966273c4544e4f58fe1b88fc8ea4bbd2b52d (diff)
Matrix: test: only show m.room.message types in room list description, sort room list by activity, improve initial sync time
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 551da5e..552ceae 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3740,11 +3740,28 @@ namespace QuickMedia {
};
// TODO: How about instead fetching all messages we have, not only the visible ones? also fetch with multiple threads.
- tabs[MESSAGES_TAB_INDEX].body->body_item_render_callback = [this, &current_room, &me, &fetch_message_future, &tabs, &fetch_message, &find_body_item_by_event_id, &fetch_body_item, &fetch_message_tab](BodyItem *body_item) {
+ tabs[MESSAGES_TAB_INDEX].body->body_item_render_callback = [this, &current_room, &me, &fetch_message_future, &tabs, &is_window_focused, &chat_state, &setting_read_marker, &read_marker_timer, &read_marker_timeout_ms, &set_read_marker_future, &find_body_item_by_event_id, &fetch_body_item, &fetch_message_tab](BodyItem *body_item) {
Message *message = static_cast<Message*>(body_item->userdata);
if(!message)
return;
+ if(message->type >= MessageType::TEXT && message->type <= MessageType::FILE && is_window_focused && chat_state != ChatState::URL_SELECTION && !setting_read_marker && read_marker_timer.getElapsedTime().asMilliseconds() >= read_marker_timeout_ms) {
+ // TODO: What if two messages have the same timestamp?
+ if(message && !message->event_id.empty() && message->timestamp > current_room->last_read_message_timestamp) {
+ //read_marker_timeout_ms = read_marker_timeout_ms_default;
+ current_room->last_read_message_timestamp = message->timestamp;
+ // TODO: What if the message is no longer valid?
+ setting_read_marker = true;
+ RoomData *room = current_room;
+ std::string event_id = message->event_id;
+ set_read_marker_future = [this, room, event_id]() mutable {
+ if(matrix->set_read_marker(room, event_id) != PluginResult::OK) {
+ fprintf(stderr, "Warning: failed to set read marker to %s\n", event_id.c_str());
+ }
+ };
+ }
+ }
+
#if 0
if(message->user->resolve_state == UserResolveState::NOT_RESOLVED) {
fetch_message = message;
@@ -4745,29 +4762,6 @@ namespace QuickMedia {
}
}
- if(selected_tab == MESSAGES_TAB_INDEX && current_room && matrix->is_initial_sync_finished()) {
- BodyItem *last_visible_item = tabs[selected_tab].body->get_last_fully_visible_item();
- if(last_visible_item && tabs[selected_tab].body->is_last_item_fully_visible() && !tabs[selected_tab].body->items.empty())
- last_visible_item = tabs[selected_tab].body->items.back().get();
- if(is_window_focused && chat_state != ChatState::URL_SELECTION && current_room && last_visible_item && !setting_read_marker && read_marker_timer.getElapsedTime().asMilliseconds() >= read_marker_timeout_ms) {
- Message *message = (Message*)last_visible_item->userdata;
- // TODO: What if two messages have the same timestamp?
- if(message && !message->event_id.empty() && message->timestamp > current_room->last_read_message_timestamp) {
- //read_marker_timeout_ms = read_marker_timeout_ms_default;
- current_room->last_read_message_timestamp = message->timestamp;
- // TODO: What if the message is no longer valid?
- setting_read_marker = true;
- RoomData *room = current_room;
- std::string event_id = message->event_id;
- set_read_marker_future = [this, room, event_id]() mutable {
- if(matrix->set_read_marker(room, event_id) != PluginResult::OK) {
- fprintf(stderr, "Warning: failed to set read marker to %s\n", event_id.c_str());
- }
- };
- }
- }
- }
-
if(selected_tab == MESSAGES_TAB_INDEX && current_room) {
window.draw(chat_input_shade);
chat_input.draw(window); //chat_input.draw(window, false);