home · contact · privacy
Simplify Channel/Topic update processing.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 19 Sep 2025 11:06:14 +0000 (13:06 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 19 Sep 2025 11:06:14 +0000 (13:06 +0200)
ircplom/client_tui.py

index 46c4106cbf2144d5cad39d4d845d8c3e8cc98de2..74d905896323c5771dfd48dbebae5ed9f59dd1bd 100644 (file)
@@ -8,7 +8,7 @@ from ircplom.tui_base import (BaseTui, PromptWidget, TuiEvent, Window,
 from ircplom.client import (
         AutoAttrMixin, Channel, Client, ClientQueueMixin, Dict, DictItem,
         IrcConnSetup, LogScope, NewClientEvent, NickUserHost, ServerCapability,
-        SharedClientDbFields, User)
+        SharedClientDbFields, Topic, User)
 
 CMD_SHORTCUTS['disconnect'] = 'window.disconnect'
 CMD_SHORTCUTS['join'] = 'window.join'
@@ -216,21 +216,16 @@ class _UpdatingChannel(_UpdatingNode, Channel):
     def _focused_set_and_report_change(
             self, old_value: '_UpdatingNode', update: _Update
             ) -> tuple[tuple[LogScope, Any], ...]:
-        scope = self._scope(update.key)
-        if update.key == 'topic':
+        if update.key == 'user_ids':
+            assert isinstance(update.value, set)
+            d = ({'NUHS:joining': tuple(sorted(id_ for id_ in update.value
+                                               if id_ not in self.user_ids))}
+                 if self.user_ids
+                 else {'NICKS:residents': tuple(sorted(update.value))})
             if super()._focused_set_and_report_change(old_value, update):
-                return ((scope,
-                        f'RAW:{self.topic.who} set topic: {self.topic.what}'),)
+                return ((self._scope(update.key), d),)
             return tuple()
-        assert update.key == 'user_ids'
-        assert isinstance(update.value, set)
-        d = ({'NUHS:joining': tuple(sorted(id_ for id_ in update.value
-                                           if id_ not in self.user_ids))}
-             if self.user_ids
-             else {'NICKS:residents': tuple(sorted(update.value))})
-        if super()._focused_set_and_report_change(old_value, update):
-            return ((scope, d),)
-        return tuple()
+        return super()._focused_set_and_report_change(old_value, update)
 
 
 class _UpdatingUser(_UpdatingNode, User):
@@ -361,6 +356,8 @@ class _ClientWindowsManager:
                 log_kwargs |= {'target': update.path[1]}
             if value is None:
                 self.log(f'{log_path} cleared', **log_kwargs)
+            elif isinstance(value, Topic):
+                self.log(f'{value.who} set topic: {value.what}', **log_kwargs)
             elif isinstance(value, dict):
                 for verb, item in [(k, v) for k, v in value.items() if v]:
                     toks = verb.split(':', maxsplit=1)