fix(web): 全新好友关系不会立即出现在会话列表/正确显示在线状态
上一条commit修的是"消息本身发不出去",这条修的是同一个根因链条上更早 一环:SDK只对`me`话题的onMetaSub/onSubsUpdated两个回调做了这个"联系 人变化了"的通知(读tinode.dev.js确认:无论是哪个话题触发的订阅,SDK 永远只调用me.onMetaSub/me.onSubsUpdated,不是触发订阅的那个话题自己 的回调),但这个项目的wireTopicCallbacks只接了onSubsUpdated,漏了 onMetaSub——这正是brand-new P2P话题从usr别名被服务端改名成真实 p2p...哈希的那一刻,SDK唯一会触发的两个回调之一。 现在两个回调都接上、都指向同一个notify(),会话列表和ConversationView 自己的contact查找(决定头部显示真实昵称还是裸id、在线还是离线)应该 能在好友关系刚建立、还没有任何一方发过消息时就正确更新,不用等一次不 相关的全量重连才被动捡回正确状态。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
0824502ddd
commit
776131b1de
Vendored
+8
@@ -246,6 +246,14 @@ declare module 'tinode-sdk' {
|
||||
onAllMessagesReceived?: (count: number) => void;
|
||||
onInfo?: (info: { what: 'read' | 'recv' | 'kp' | 'call'; seq?: number; from?: string; event?: string; payload?: Record<string, unknown> }) => void;
|
||||
onMetaDesc?: (desc: unknown) => void;
|
||||
/** `me`-topic-only in practice (verified tinode.dev.js:4654-4657): fired with the just-subscribed
|
||||
* Topic itself the moment a brand-new contact's subscribe resolves -- notably including the
|
||||
* usr-alias -> real-topic-name rename case (Topic#subscribe, same code block that updates
|
||||
* `this.name`). Distinct from `onSubsUpdated` below (which the SDK ALSO fires in that same
|
||||
* block, with just the name/count) -- wired to the identical notify callback here since both
|
||||
* ultimately mean the same thing for this app's purposes: "the chat list's contact set changed,
|
||||
* recompute it." */
|
||||
onMetaSub?: (topic: Topic) => void;
|
||||
onSubsUpdated?: (subs: string[], count?: number) => void;
|
||||
onPres?: (pres: unknown) => void;
|
||||
onAuxUpdated?: (aux: unknown) => void;
|
||||
|
||||
@@ -73,6 +73,15 @@ function wireTopicCallbacks(topic: Topic) {
|
||||
if (info) infoListeners.forEach((cb) => cb(topic.name, info));
|
||||
};
|
||||
topic.onMetaDesc = notify;
|
||||
// Only ever actually invoked on the `me` topic (the SDK reads `me.onMetaSub`/`me.onSubsUpdated`
|
||||
// specifically, regardless of which topic's subscribe triggered it -- confirmed tinode.dev.js:
|
||||
// 4654-4659) -- wiring it here on every topic is a no-op for anything else, same as onSubsUpdated
|
||||
// right below, which already gets this same treatment. Without this, a brand-new P2P conversation
|
||||
// reached by the other user's `usr...` id (no established topic yet) never tells the chat list a
|
||||
// new contact exists the instant the server assigns its real `p2p...` name on first subscribe --
|
||||
// the contact stays invisible in the sidebar, and ConversationView's own `contact` lookup (peer
|
||||
// name, online status) keeps missing until some UNRELATED full resync happens to pick it up.
|
||||
topic.onMetaSub = notify;
|
||||
topic.onSubsUpdated = notify;
|
||||
topic.onPres = notify;
|
||||
topic.onAuxUpdated = notify;
|
||||
|
||||
Reference in New Issue
Block a user