From 5748f1290d1e083dea7fe931751ed0141c5ec7e9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 18 Sep 2026 17:36:11 +0800 Subject: [PATCH] fix(groups): sync group rename in real time for owner and members PATCH .../groups/{topic} pushes a custom {info what:"group", event:"group.profile.updated"} that nothing recognized, so the sidebar/header name (native SDK contact.public.fn) never refreshed until an unrelated focus-triggered resync happened to touch it. Add the missing branch to onInfo (mirrors the existing group.dissolved/message.recalled handling) to re-pull public/desc via topic.getMeta(...withDesc()), and trigger the same refresh from the renamer's own save success since they won't receive their own push. Co-Authored-By: Claude Sonnet 5 --- web/src/features/groups/GroupDetailColumn.tsx | 5 +++++ web/src/lib/tinode/topics.ts | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/web/src/features/groups/GroupDetailColumn.tsx b/web/src/features/groups/GroupDetailColumn.tsx index ce47638e..fdb842ab 100644 --- a/web/src/features/groups/GroupDetailColumn.tsx +++ b/web/src/features/groups/GroupDetailColumn.tsx @@ -171,6 +171,11 @@ export function GroupDetailColumn({ topicId, peerName, onClose, onOpenHistory }: onSuccess: (data) => { queryClient.setQueryData(['group', topicId], (prev: GroupProfile | undefined) => (prev ? { ...prev, ...data } : data)); setNameEditing(false); + // The renamer's OWN sidebar/header (`contact.public?.fn`, native SDK state) doesn't update from + // this REST call either -- only from the `group.profile.updated` push topics.ts now listens for, + // which this account won't receive for its own action. Trigger the same SDK-sanctioned refresh + // directly instead of waiting on an unconfirmed self-echo of that push. + tinode.getTopic(topicId).getMeta(tinode.getTopic(topicId).startMetaQuery().withDesc().build()).catch(() => {}); }, onError: (err) => showError(err, '群名保存失败'), }); diff --git a/web/src/lib/tinode/topics.ts b/web/src/lib/tinode/topics.ts index f008d6ad..648eea0c 100644 --- a/web/src/lib/tinode/topics.ts +++ b/web/src/lib/tinode/topics.ts @@ -298,6 +298,20 @@ function wireTopicCallbacks(topic: Topic) { topic.getMeta(topic.startMetaQuery().withData(seq, seq + 1, 1).build()).catch(() => {}); } } + // docs/IM-前后端对接文档.md:1542: `PATCH .../groups/{topic}` (rename/avatar/description) pushes a + // custom `{info what:"group", event:"group.profile.updated"}` to every other online member -- same + // undocumented-to-the-SDK shape as `group.dissolved` above, so nothing here ever refreshed the + // topic's native `public` fields on receipt. Live-confirmed the actual gap: the sidebar/header name + // comes from `contact.public?.fn` (native SDK state, see ChatListColumn.tsx), which a REST-only + // mutation never touches for ANYONE -- not just other members, but the renamer's own other tabs/ + // views too -- and only ever got refreshed as a side effect of the unrelated focus-triggered + // `reconcileMeSubs()`, which is why refocus "fixed" it for everyone. `withDesc()` is the SDK's own + // sanctioned way to re-pull `public`/description from the server (contrast the abandoned approach + // of manually patching `Topic._processMetaDesc` tried earlier for a different bug -- that one was + // reverted for inconclusive verification; this one goes through a real server round-trip instead). + if (groupEvent?.what === 'group' && groupEvent.event === 'group.profile.updated') { + topic.getMeta(topic.startMetaQuery().withDesc().build()).catch(() => {}); + } }; topic.onMetaDesc = notify; // Only ever actually invoked on the `me` topic (the SDK reads `me.onMetaSub`/`me.onSubsUpdated`