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


Commits:
4d42b782 by wurstsalat at 2025-01-19T21:18:47+01:00
cfix: Fix more app.window.add_chat() calls; add more typings

- - - - -


3 changed files:

- gajim/gtk/chat_list.py
- gajim/gtk/chat_list_row.py
- gajim/gtk/menus.py


Changes:

=====================================
gajim/gtk/chat_list.py
=====================================
@@ -6,6 +6,7 @@
 
 from typing import Any
 from typing import cast
+from typing import Literal
 
 import logging
 from collections.abc import Iterator
@@ -142,10 +143,12 @@ def set_filter_text(self, text: str) -> None:
         self._current_filter_text = text
         self.invalidate_filter()
 
-    def get_chat_type(self, account: str, jid: JID) -> str | None:
+    def get_chat_type(
+        self, account: str, jid: JID
+    ) -> Literal["chat", "groupchat", "pm"] | None:
         row = self._chats.get((account, jid))
         if row is not None:
-            return row.type
+            return row.type  # type: ignore
         return None
 
     def get_selected_chat(self) -> ChatListRow | None:
@@ -162,7 +165,7 @@ def get_open_chats(self) -> OpenChatsSettingT:
                 {
                     "account": account,
                     "jid": jid,
-                    "type": row.type,
+                    "type": row.type,  # type: ignore
                     "pinned": row.is_pinned,
                     "position": row.position,
                 }
@@ -189,7 +192,12 @@ def toggle_chat_pinned(self, account: str, jid: JID) -> 
None:
         self.invalidate_sort()
 
     def add_chat(
-        self, account: str, jid: JID, type_: str, pinned: bool, position: int
+        self,
+        account: str,
+        jid: JID,
+        type_: Literal["chat", "groupchat", "pm"],
+        pinned: bool,
+        position: int,
     ) -> None:
 
         key = (account, jid)


=====================================
gajim/gtk/chat_list_row.py
=====================================
@@ -5,6 +5,7 @@
 from __future__ import annotations
 
 from typing import Any
+from typing import Literal
 
 from datetime import datetime
 from urllib.parse import urlparse
@@ -58,7 +59,7 @@ def __init__(
         workspace_id: str,
         account: str,
         jid: JID,
-        type_: str,
+        type_: Literal["chat", "groupchat", "pm"],
         pinned: bool,
         position: int,
     ) -> None:


=====================================
gajim/gtk/menus.py
=====================================
@@ -472,7 +472,7 @@ def get_account_notifications_menu(account: str) -> 
GajimMenu:
 
 
 def get_subscription_menu(account: str, jid: JID) -> GajimMenu:
-    params = AddChatActionParams(account=account, jid=jid, type="contact", 
select=True)
+    params = AddChatActionParams(account=account, jid=jid, type="chat", 
select=True)
     value = str(jid)
     menuitems: MenuItemListT = [
         (_("Start Chat"), "win.add-chat", params),



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/4d42b782d7b86c02dfb51c701798a7a64461260e
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to