changeset 2992:4d5b9d4c7448

primitivus (chat): don't show minor notifications (all but mentions) when printing history fix 316
author Goffi <goffi@goffi.org>
date Mon, 08 Jul 2019 09:20:06 +0200 (2019-07-08)
parents f4590ca2acff
children d58dccd9e4b4
files sat_frontends/primitivus/chat.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/primitivus/chat.py	Sun Jul 07 15:39:53 2019 +0200
+++ b/sat_frontends/primitivus/chat.py	Mon Jul 08 09:20:06 2019 +0200
@@ -426,11 +426,16 @@
             self.mess_widgets.focus_position = bottom  # scroll down
         self.host.redraw()  # FIXME: should not be necessary
 
-    def appendMessage(self, message):
+    def appendMessage(self, message, minor_notifs=True):
         """Create a MessageWidget and append it
 
-        Can merge messages together is desirable (e.g.: multiple joined/leave)
+        Can merge info messages together if desirable (e.g.: multiple joined/leave)
         @param message(quick_chat.Message): message to add
+        @param minor_notifs(boolean): if True, basic notifications are allowed
+            If False, notification are not shown except if we have an important one
+            (like a mention).
+            False is generally used when printing history, when we don't want every
+            message to be notified.
         """
         if self.filters:
             if not all([f(message) for f in self.filters]):
@@ -481,6 +486,8 @@
             self.host.notify(
                 C.NOTIFY_MENTION, from_jid, msg, widget=self, profile=self.profile
             )
+        elif not minor_notifs:
+            return
         elif self.type == C.CHAT_ONE2ONE:
             from_jid = wid.mess_data.from_jid
             msg = _(u"{entity} is talking to you".format(entity=from_jid))
@@ -567,7 +574,7 @@
         if clear:
             del self.mess_walker[:]
         for message in self.messages.itervalues():
-            self.appendMessage(message)
+            self.appendMessage(message, minor_notifs=False)
 
     def redraw(self):
         """redraw all messages"""