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


Commits:
2804e759 by wurstsalat at 2021-11-20T12:37:25+01:00
Add message to Control if it's loaded

This avoids messages not being added to a conversation when switching
to another workspace, then switching back to the same chat.

- - - - -


3 changed files:

- gajim/gtk/chat_page.py
- gajim/gtk/controls/base.py
- gajim/gtk/main.py


Changes:

=====================================
gajim/gtk/chat_page.py
=====================================
@@ -82,7 +82,7 @@ def __init__(self):
         self._ui.paned.set_position(app.settings.get('chat_handle_position'))
         self._ui.paned.connect('button-release-event', self._on_button_release)
 
-        self._active_control: Optional[BaseControl] = None
+        self._currently_loaded_control: Optional[BaseControl] = None
         self._startup_finished: bool = False
 
         self._add_actions()
@@ -142,11 +142,11 @@ def _on_chat_selected(self, _chat_list_stack: 
ChatListStack,
         control = self.get_control(account, jid)
         if control is None:
             return
-        if self._active_control != control:
-            if self._active_control is not None:
-                self._active_control.set_control_active(False)
+        if self._currently_loaded_control != control:
+            if self._currently_loaded_control is not None:
+                self._currently_loaded_control.set_control_active(False)
             control.set_control_active(True)
-        self._active_control = control
+        self._currently_loaded_control = control
 
     def _on_chat_unselected(self, _chat_list_stack):
         self._chat_stack.clear()
@@ -284,6 +284,9 @@ def get_active_control(self) -> Optional[BaseControl]:
             return None
         return self.get_control(chat.account, chat.jid)
 
+    def get_currently_loaded_control(self) -> Optional[BaseControl]:
+        return self._currently_loaded_control
+
     def get_controls(self, account: Optional[str]
                      ) -> Generator[BaseControl, None, None]:
         return self._chat_stack.get_controls(account)


=====================================
gajim/gtk/controls/base.py
=====================================
@@ -1101,12 +1101,14 @@ def add_file_transfer(self, transfer):
         self.conversation_view.add_file_transfer(transfer)
 
     def add_jingle_file_transfer(self, event):
-        control_selected = bool(self == app.window.get_active_control())
+        control_selected = bool(
+            self == app.window.get_currently_loaded_control())
         if self._scrolled_view.get_lower_complete() and control_selected:
             self.conversation_view.add_jingle_file_transfer(event)
 
     def add_call_message(self, event):
-        control_selected = bool(self == app.window.get_active_control())
+        control_selected = bool(
+            self == app.window.get_currently_loaded_control())
         if self._scrolled_view.get_lower_complete() and control_selected:
             self.conversation_view.add_call_message(event=event)
 
@@ -1126,7 +1128,8 @@ def add_message(self,
         if additional_data is None:
             additional_data = AdditionalDataDict()
 
-        control_selected = bool(self == app.window.get_active_control())
+        control_selected = bool(
+            self == app.window.get_currently_loaded_control())
         if self._scrolled_view.get_lower_complete() and control_selected:
             self.conversation_view.add_message(
                 text,


=====================================
gajim/gtk/main.py
=====================================
@@ -480,6 +480,9 @@ def get_controls(self, account: Optional[str] = None
     def get_active_control(self) -> Optional[BaseControl]:
         return self._chat_page.get_active_control()
 
+    def get_currently_loaded_control(self) -> Optional[BaseControl]:
+        return self._chat_page.get_currently_loaded_control()
+
     def chat_exists(self, account: str, jid: JID) -> bool:
         return self._chat_page.chat_exists(account, jid)
 



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

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