Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
74a94b6a by wurstsalat at 2022-01-10T17:17:23+01:00
Add new PM chat to the same workspace the MUC resides in
- - - - -
2 changed files:
- gajim/gtk/chat_list_stack.py
- gajim/gtk/main.py
Changes:
=====================================
gajim/gtk/chat_list_stack.py
=====================================
@@ -182,7 +182,7 @@ def add_chat(self, workspace_id: str, account: str, jid:
JID, type_: str,
chat_list.add_chat(account, jid, type_, pinned)
def select_chat(self, account: str, jid: JID) -> None:
- chat_list = self._find_chat(account, jid)
+ chat_list = self.find_chat(account, jid)
if chat_list is None:
return
@@ -241,7 +241,7 @@ def remove_chats_for_account(self, account: str) -> None:
chat_list.remove_chats_for_account(account)
self.store_open_chats(workspace_id)
- def _find_chat(self, account: str, jid: JID) -> Optional[ChatList]:
+ def find_chat(self, account: str, jid: JID) -> Optional[ChatList]:
for chat_list in self._chat_lists.values():
if chat_list.contains_chat(account, jid):
return chat_list
@@ -292,7 +292,7 @@ def process_event(self, event: ApplicationEvent) -> None:
if event.name not in HANDLED_EVENTS:
return
- chat_list = self._find_chat(event.account, event.jid)
+ chat_list = self.find_chat(event.account, event.jid)
if chat_list is None:
return
chat_list.process_event(event)
=====================================
gajim/gtk/main.py
=====================================
@@ -349,7 +349,7 @@ def show_account_page(self, account: str) -> None:
self._account_side_bar.activate_account_page(account)
self._main_stack.show_account(account)
- def get_active_workspace(self) -> Optional[Workspace]:
+ def get_active_workspace(self) -> Optional[str]:
return self._workspace_side_bar.get_active_workspace()
def is_chat_active(self, account: str, jid: JID) -> bool:
@@ -458,6 +458,8 @@ def add_chat(self,
workspace: str = 'default') -> None:
if workspace == 'current':
workspace_id = self.get_active_workspace()
+ if workspace_id is None:
+ workspace_id = self._workspace_side_bar.get_first_workspace()
else:
workspace_id = self._workspace_side_bar.get_first_workspace()
self._chat_page.add_chat_for_workspace(workspace_id,
@@ -466,11 +468,18 @@ def add_chat(self,
type_,
select=select)
- def add_private_chat(self, account: str, jid: JID,
+ def add_private_chat(self,
+ account: str,
+ jid: JID,
select: bool = False) -> None:
- workspace_id = self.get_active_workspace()
- if workspace_id is None:
+ # Try to add private chat to the same workspace the MUC resides in
+ chat_list_stack = self._chat_page.get_chat_list_stack()
+ chat_list = chat_list_stack.find_chat(account, jid.new_as_bare())
+ if chat_list is not None:
+ workspace_id = chat_list.workspace_id
+ else:
workspace_id = self._workspace_side_bar.get_first_workspace()
+
self._chat_page.add_chat_for_workspace(workspace_id,
account,
jid,
@@ -659,8 +668,7 @@ def _on_event(self, event):
return
if event.properties.is_muc_pm:
self.add_private_chat(event.account,
- event.properties.jid,
- 'pm')
+ event.properties.jid)
else:
jid = event.properties.jid.new_as_bare()
self.add_chat(event.account, jid, 'contact')
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/74a94b6a7e97febb7c78967d3f581e7f3462f220
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/74a94b6a7e97febb7c78967d3f581e7f3462f220
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