home · contact · privacy
Differentiate query windows into their own chat windows subclass.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 5 Sep 2025 11:52:54 +0000 (13:52 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 5 Sep 2025 11:52:54 +0000 (13:52 +0200)
ircplom/client_tui.py

index 0b14b9c5e7eca18dea990b5dd04f4604bba35d4d..42bd8c7830679bce2d6c1b9159179759753c6b91 100644 (file)
@@ -193,6 +193,10 @@ class _ChannelWindow(_ChatWindow):
         self._send_msg('PART', (self.chatname,))
 
 
+class _QueryWindow(_ChatWindow):
+    pass
+
+
 class _UpdatingChannel(_UpdatingNode):
     user_ids: tuple[str, ...] = tuple()
     topic: Topic = Topic()
@@ -264,7 +268,7 @@ class _ClientWindowsManager:
         if scope == LogScope.CHAT:
             kwargs['win_cls'] = (
                     _ChannelWindow if self.db.is_chan_name(chatname)
-                    else _ChatWindow)
+                    else _QueryWindow)
             kwargs['chatname'] = chatname
             kwargs['get_nick_data'] = lambda: self.db.users['me'].nick
         win = self._tui_new_window(**kwargs)
@@ -288,13 +292,12 @@ class _ClientWindowsManager:
         chan_names = [c for c, v in self.db.channels.items()
                       if user_id in v.user_ids]
         return [w for w in self.windows
-                if isinstance(w, _ChatWindow)
-                and ((isinstance(w, _ChannelWindow)
-                      and w.chatname in chan_names)
-                     or (not isinstance(w, _ChannelWindow)
-                         and w.chatname in {
-                             self.db.users[user_id].nick,
-                             self.db.users[user_id].prev_nick}))]
+                if ((isinstance(w, _ChannelWindow)
+                     and w.chatname in chan_names)
+                    or (isinstance(w, _QueryWindow)
+                        and w.chatname in {
+                            self.db.users[user_id].nick,
+                            self.db.users[user_id].prev_nick}))]
 
     def log(self, msg: str, scope: LogScope, **kwargs) -> None:
         'From parsing scope, kwargs, build prefix before sending to logger.'