Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits: ef621f99 by wurstsalat at 2021-10-16T14:21:09+02:00 Chat Markers: Fix read state sync - - - - - 3 changed files: - gajim/gtk/controls/base.py - gajim/gtk/main.py - gajim/gui_interface.py Changes: ===================================== gajim/gtk/controls/base.py ===================================== @@ -534,15 +534,16 @@ def remove_actions(self): for action in actions: app.window.remove_action(f'{action}{self.control_id}') - def mark_as_read(self): + def mark_as_read(self, send_marker=True): self._jump_to_end_button.reset_unread_count() - # XEP-0333 Send <displayed> marker - self._client.get_module('ChatMarkers').send_displayed_marker( - self.contact, - self.last_msg_id, - self._type) - self.last_msg_id = None + if send_marker: + # XEP-0333 Send <displayed> marker + self._client.get_module('ChatMarkers').send_displayed_marker( + self.contact, + self.last_msg_id, + self._type) + self.last_msg_id = None def change_encryption(self, action, param): encryption = param.get_string() ===================================== gajim/gtk/main.py ===================================== @@ -460,13 +460,13 @@ def get_chat_unread_count(self, account, jid): count = chat_list_stack.get_chat_unread_count(account, jid) return count or 0 - def mark_as_read(self, account, jid): + def mark_as_read(self, account, jid, send_marker=True): # TODO set window urgency hint, etc. control = self.get_control(account, jid) if control is not None: # Send displayed marker and # reset jump to bottom button unread counter - control.mark_as_read() + control.mark_as_read(send_marker=send_marker) # Reset chat list unread counter (emits unread-count-changed) chat_list_stack = self._chat_page.get_chat_list_stack() chat_list_stack.mark_as_read(account, jid) ===================================== gajim/gui_interface.py ===================================== @@ -517,31 +517,18 @@ def handle_event_msgnotsent(event): def handle_event_read_state_sync(event): if event.type.is_groupchat: jid = event.jid.bare - types = ['group-chat-message'] - else: jid = event.jid - types = ['chat-message', 'private-chat-message'] control = app.window.get_control(event.account, jid) if control is None: log.warning('No ChatControl found') return - events_ = app.events.get_events(event.account, jid, types) - if not events_: - log.warning('No Events') - return - - if event.type.is_groupchat: - id_ = events_[-1].stanza_id or events_[-1].message_id - else: - id_ = events_[-1].message_id - - if id_ != event.marker_id: + if event.marker_id != control.last_msg_id: return - app.events.remove_events(event.account, jid, types=types) + app.window.mark_as_read(event.account, jid, send_marker=False) @staticmethod def handle_event_metacontacts(obj): View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/ef621f9987bc025cd0ae1bb9b95a51f6ebd686a4 -- View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/ef621f9987bc025cd0ae1bb9b95a51f6ebd686a4 You're receiving this email because of your account on dev.gajim.org.
_______________________________________________ Commits mailing list Commits@gajim.org https://lists.gajim.org/cgi-bin/listinfo/commits