Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
857f654c by wurstsalat at 2022-08-31T22:47:20+02:00
cfix: ReadMarkers: Fix read-state-sync and sending markers
Fixes #11114
- - - - -
3 changed files:
- gajim/common/modules/chat_markers.py
- gajim/gtk/control.py
- gajim/gtk/main.py
Changes:
=====================================
gajim/common/modules/chat_markers.py
=====================================
@@ -76,6 +76,7 @@ def _process_chat_marker(self,
if properties.is_mam_message:
if properties.from_.bare_match(self._client.get_own_jid()):
+ self._raise_event('read-state-sync', properties)
return
self._raise_event('displayed-received', properties)
=====================================
gajim/gtk/control.py
=====================================
@@ -97,9 +97,6 @@ def __init__(self) -> None:
# Used with encryption plugins
self.sendmessage = False
- # XEP-0333 Chat Markers
- self.last_msg_id: Optional[str] = None
-
self._muc_subjects: dict[
types.ChatContactT, tuple[float, MucSubject]] = {}
@@ -153,7 +150,6 @@ def clear(self) -> None:
self._contact = None
self._client = None
- self.last_msg_id = None
self.reset_view()
self._scrolled_view.clear()
self._groupchat_state.clear()
@@ -456,13 +452,6 @@ def is_groupchat(self) -> bool:
def mark_as_read(self, send_marker: bool = True) -> None:
self._jump_to_end_button.reset_unread_count()
- if send_marker and self.last_msg_id is not None:
- # XEP-0333 Send <displayed> marker
- self.client.get_module('ChatMarkers').send_displayed_marker(
- self.contact,
- self.last_msg_id)
- self.last_msg_id = None
-
def _on_autoscroll_changed(self,
_widget: ScrolledView,
autoscroll: bool
@@ -569,12 +558,6 @@ def _add_message(self,
else:
self._jump_to_end_button.add_unread_count()
- if message_id and kind == 'incoming':
- if self.is_groupchat:
- self.last_msg_id = stanza_id or message_id
- else:
- self.last_msg_id = message_id
-
def reset_view(self) -> None:
self._scrolled_view.reset()
=====================================
gajim/gtk/main.py
=====================================
@@ -840,17 +840,30 @@ def mark_as_read(self,
send_marker: bool = True
) -> None:
+ unread_count = self.get_chat_unread_count(account, jid)
+
set_urgency_hint(self, False)
control = self.get_control()
if control.has_active_chat():
- # Send displayed marker and
- # reset jump to bottom button unread counter
+ # Reset jump to bottom button unread counter
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)
+ if not send_marker or not unread_count:
+ # Read marker must be sent only once
+ return
+
+ last_message = app.storage.archive.get_last_conversation_line(
+ account, jid)
+ client = app.get_client(account)
+ contact = client.get_module('Contacts').get_contact(jid)
+ client.get_module('ChatMarkers').send_displayed_marker(
+ contact,
+ last_message.message_id)
+
def _on_window_active(self,
window: Gtk.ApplicationWindow,
_param: Any
@@ -966,12 +979,10 @@ def _on_read_state_sync(self, event:
events.ReadStateSync) -> None:
else:
jid = event.jid
- control = self.get_control()
- if not control.is_loaded(event.account, jid):
- return
+ last_message = app.storage.archive.get_last_conversation_line(
+ event.account, jid)
- # TODO: last_msg_id does not work and needs to be refactored
- if event.marker_id != control.last_msg_id:
+ if event.marker_id != last_message.message_id:
return
self.mark_as_read(event.account, jid, send_marker=False)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/857f654cd9fe6cbd9a0b374a277a62a7b85def28
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/857f654cd9fe6cbd9a0b374a277a62a7b85def28
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits