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


Commits:
12bc0c21 by wurstsalat at 2021-11-13T20:59:05+01:00
ChatList: Set stanza_id correctly when receiving MAM messages

- - - - -
256dd758 by wurstsalat at 2021-11-14T00:03:15+01:00
Don't fail if active workspace is None

- - - - -
1d8eb84b by wurstsalat at 2021-11-14T00:06:14+01:00
Notifications: Suppress for MAM messages

- - - - -


5 changed files:

- gajim/gtk/chat_list.py
- gajim/gtk/controls/base.py
- gajim/gtk/controls/chat.py
- gajim/gtk/controls/groupchat.py
- gajim/gtk/main.py


Changes:

=====================================
gajim/gtk/chat_list.py
=====================================
@@ -340,11 +340,13 @@ def _on_message_received(self, event):
         row.set_nick(nick)
         if event.name == 'mam-message-received':
             row.set_timestamp(event.properties.mam.timestamp)
+            row.set_stanza_id(event.stanza_id)
         else:
             row.set_timestamp(event.properties.timestamp)
+            row.set_stanza_id(event.properties.stanza_id.id)
         row.set_message_text(
             event.msgtxt, additional_data=event.additional_data)
-        row.set_stanza_id(event.properties.stanza_id.id)
+
         self._add_unread(row, event.properties)
         self.invalidate_sort()
 


=====================================
gajim/gtk/controls/base.py
=====================================
@@ -1111,6 +1111,7 @@ def add_message(self,
                     kind,
                     name,
                     tim,
+                    notify,
                     displaymarking=None,
                     msg_log_id=None,
                     message_id=None,
@@ -1154,7 +1155,8 @@ def add_message(self,
             self.save_message(text, 'received')
 
             # Issue notification
-            self._notify(name, text, tim)
+            if notify:
+                self._notify(name, text, tim)
 
             # Send chat marker if we’re actively following the chat
             chat_active = app.window.is_chat_active(


=====================================
gajim/gtk/controls/chat.py
=====================================
@@ -415,7 +415,8 @@ def _on_mam_message_received(self, event):
                          correct_id=event.correct_id,
                          message_id=event.properties.id,
                          stanza_id=event.stanza_id,
-                         additional_data=event.additional_data)
+                         additional_data=event.additional_data,
+                         notify=False)
 
     def _on_message_received(self, event):
         if not event.msgtxt:
@@ -605,7 +606,8 @@ def add_message(self,
                     stanza_id=None,
                     correct_id=None,
                     message_id=None,
-                    additional_data=None):
+                    additional_data=None,
+                    notify=True):
 
         if additional_data is None:
             additional_data = AdditionalDataDict()
@@ -620,6 +622,7 @@ def add_message(self,
                                 kind,
                                 name,
                                 tim,
+                                notify,
                                 displaymarking=displaymarking,
                                 msg_log_id=msg_log_id,
                                 message_id=message_id,


=====================================
gajim/gtk/controls/groupchat.py
=====================================
@@ -674,7 +674,8 @@ def _on_mam_message_received(self, event):
                          correct_id=event.correct_id,
                          message_id=event.properties.id,
                          stanza_id=event.stanza_id,
-                         additional_data=event.additional_data)
+                         additional_data=event.additional_data,
+                         notify=False)
 
     def _on_gc_message_received(self, event):
         if event.properties.muc_nickname is None:
@@ -710,7 +711,8 @@ def add_message(self,
                     correct_id=None,
                     message_id=None,
                     stanza_id=None,
-                    additional_data=None):
+                    additional_data=None,
+                    notify=True):
 
         if contact == self.contact.nickname:
             kind = 'outgoing'
@@ -729,6 +731,7 @@ def add_message(self,
                                 kind,
                                 contact,
                                 tim,
+                                notify,
                                 displaymarking=displaymarking,
                                 correct_id=correct_id,
                                 message_id=message_id,


=====================================
gajim/gtk/main.py
=====================================
@@ -1,3 +1,5 @@
+from typing import Optional
+
 import logging
 import os
 
@@ -16,6 +18,7 @@
 from .adhoc import AdHocCommand
 from .account_side_bar import AccountSideBar
 from .app_side_bar import AppSideBar
+from .workspace_side_bar import Workspace
 from .workspace_side_bar import WorkspaceSideBar
 from .main_stack import MainStack
 from .dialogs import DialogButton
@@ -323,7 +326,7 @@ def show_account_page(self, account):
         self._account_side_bar.activate_account_page(account)
         self._main_stack.show_account(account)
 
-    def get_active_workspace(self):
+    def get_active_workspace(self) -> Optional[Workspace]:
         return self._workspace_side_bar.get_active_workspace()
 
     def is_chat_active(self, account, jid):
@@ -390,6 +393,8 @@ def _add_group_chat(self, _action, param):
 
     def add_group_chat(self, account, jid, select=False):
         workspace_id = self.get_active_workspace()
+        if workspace_id is None:
+            workspace_id = self._workspace_side_bar.get_first_workspace()
         self._chat_page.add_chat_for_workspace(workspace_id,
                                                account,
                                                jid,
@@ -411,6 +416,8 @@ def add_chat(self, account, jid, type_, select=False):
 
     def add_private_chat(self, account, jid, select=False):
         workspace_id = self.get_active_workspace()
+        if workspace_id is None:
+            workspace_id = self._workspace_side_bar.get_first_workspace()
         self._chat_page.add_chat_for_workspace(workspace_id,
                                                account,
                                                jid,



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/8660c9b6da254b26dc0bf88ad7b1c160155f4a68...1d8eb84be6d98b14b77943a15a179307d943f840

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/8660c9b6da254b26dc0bf88ad7b1c160155f4a68...1d8eb84be6d98b14b77943a15a179307d943f840
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