Daniel Brötzmann pushed to branch mainwindow at gajim / gajim


Commits:
b8275942 by wurstsalat at 2021-11-28T13:58:33+01:00
Add silent unread markers

- - - - -


3 changed files:

- gajim/data/style/gajim.css
- gajim/gtk/chat_list.py
- gajim/gtk/controls/base.py


Changes:

=====================================
gajim/data/style/gajim.css
=====================================
@@ -393,6 +393,9 @@ .unread-counter {
     padding-right: 6px;
     border-radius: 10px;
 }
+.unread-counter-silent {
+    background-color: rgb(95, 95, 95);
+}
 .header-box label {
        padding: 12px 18px 6px 18px;
        font-weight: bold;


=====================================
gajim/gtk/chat_list.py
=====================================
@@ -99,7 +99,6 @@ def mark_as_read(self, account: str, jid: JID) -> None:
         chat = self._chats.get((account, jid))
         if chat is not None:
             chat.reset_unread()
-            self.emit_unread_changed()
 
     def emit_unread_changed(self) -> None:
         count = self.get_unread_count()
@@ -508,6 +507,10 @@ def __init__(self, workspace_id: str, account: str, jid: 
JID, type_: str,
         self.update_name()
         self.update_account_identifier()
 
+        if self.contact.is_groupchat and not self.contact.can_notify():
+            self._ui.unread_label.get_style_context().add_class(
+               'unread-counter-silent')
+
         # Get last chat message from archive
         line = app.storage.archive.get_last_conversation_line(account, jid)
 
@@ -654,6 +657,8 @@ def _on_nickname_update(self, _contact, _signal_name):
 
     @property
     def unread_count(self) -> int:
+        if self.contact.is_groupchat and not self.contact.can_notify():
+            return 0
         return self._unread_count
 
     @unread_count.setter
@@ -662,6 +667,31 @@ def unread_count(self, value: int) -> None:
         self._update_unread()
         self.get_parent().emit_unread_changed()
 
+    def _update_unread(self) -> None:
+        unread_count = self._get_unread_string(self._unread_count)
+        self._ui.unread_label.set_text(unread_count)
+        self._ui.unread_label.set_visible(bool(self._unread_count))
+
+    @staticmethod
+    def _get_unread_string(count: int) -> str:
+        if count < 1000:
+            return str(count)
+        return '999+'
+
+    def add_unread(self) -> None:
+        control = app.window.get_control(self.account, self.jid)
+        if self.is_active and control.get_autoscroll():
+            return
+
+        self._unread_count += 1
+        self._update_unread()
+        self.get_parent().emit_unread_changed()
+
+    def reset_unread(self) -> None:
+        self._unread_count = 0
+        self._update_unread()
+        self.get_parent().emit_unread_changed()
+
     @property
     def is_active(self) -> bool:
         return (self.is_selected() and
@@ -701,31 +731,6 @@ def update_time(self) -> None:
         self._ui.timestamp_label.set_text(
             get_uf_relative_time(self.timestamp))
 
-    def _update_unread(self) -> None:
-        unread_count = self._get_unread_string(self._unread_count)
-        self._ui.unread_label.set_text(unread_count)
-        self._ui.unread_label.set_visible(bool(self._unread_count))
-
-    @staticmethod
-    def _get_unread_string(count: int) -> str:
-        if count < 1000:
-            return str(count)
-        return '999+'
-
-    def add_unread(self) -> None:
-        control = app.window.get_control(self.account, self.jid)
-        if self.is_active and control.get_autoscroll():
-            return
-
-        self.unread_count += 1
-        if self.unread_count == 1:
-            self.changed()
-
-    def reset_unread(self) -> None:
-        if not self.unread_count:
-            return
-        self.unread_count = 0
-
     def set_nick(self, nickname: str) -> None:
         self._ui.nick_label.set_visible(bool(nickname))
         self._ui.nick_label.set_text(nickname)


=====================================
gajim/gtk/controls/base.py
=====================================
@@ -565,7 +565,7 @@ def remove_actions(self) -> None:
     def mark_as_read(self, send_marker: bool = True) -> None:
         self._jump_to_end_button.reset_unread_count()
 
-        if send_marker:
+        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,
@@ -976,10 +976,8 @@ def _on_autoscroll_changed(self, _widget, autoscroll):
             self._jump_to_end_button.toggle(True)
             return
 
-        if app.window.get_chat_unread_count(self.account, self.contact.jid) > 
0:
-            app.window.mark_as_read(self.account, self.contact.jid)
-
         self._jump_to_end_button.toggle(False)
+        app.window.mark_as_read(self.account, self.contact.jid)
 
     def _on_jump_to_end(self, _button):
         self.scroll_to_end(force=True)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/b8275942923f28a56b92587046dbfd271d2af68c

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/b8275942923f28a56b92587046dbfd271d2af68c
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

Reply via email to