Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwurstsalat <mailtrash@posteo.de>2022-08-31 23:47:03 +0300
committerwurstsalat <mailtrash@posteo.de>2022-08-31 23:47:20 +0300
commit857f654cd9fe6cbd9a0b374a277a62a7b85def28 (patch)
tree4162f259e060c3d5877fa52cff289089833ac272
parenta8fd4a1f47749524766b1cb5f5a9e1b5cf00f521 (diff)
cfix: ReadMarkers: Fix read-state-sync and sending markers
Fixes #11114
-rw-r--r--gajim/common/modules/chat_markers.py1
-rw-r--r--gajim/gtk/control.py17
-rw-r--r--gajim/gtk/main.py25
3 files changed, 19 insertions, 24 deletions
diff --git a/gajim/common/modules/chat_markers.py b/gajim/common/modules/chat_markers.py
index 67c5b5a7d..2feaebd9d 100644
--- a/gajim/common/modules/chat_markers.py
+++ b/gajim/common/modules/chat_markers.py
@@ -76,6 +76,7 @@ class ChatMarkers(BaseModule):
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)
diff --git a/gajim/gtk/control.py b/gajim/gtk/control.py
index f0e388375..c34cb831e 100644
--- a/gajim/gtk/control.py
+++ b/gajim/gtk/control.py
@@ -97,9 +97,6 @@ class ChatControl(EventHelper):
# 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 @@ class ChatControl(EventHelper):
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 @@ class ChatControl(EventHelper):
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 @@ class ChatControl(EventHelper):
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()
diff --git a/gajim/gtk/main.py b/gajim/gtk/main.py
index 340ee3f29..9fdfcbd70 100644
--- a/gajim/gtk/main.py
+++ b/gajim/gtk/main.py
@@ -840,17 +840,30 @@ class MainWindow(Gtk.ApplicationWindow, EventHelper):
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 @@ class MainWindow(Gtk.ApplicationWindow, EventHelper):
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)