diff --git a/web/src/lib/tinode/tinode-sdk.d.ts b/web/src/lib/tinode/tinode-sdk.d.ts index 89544a37..c519d8e8 100644 --- a/web/src/lib/tinode/tinode-sdk.d.ts +++ b/web/src/lib/tinode/tinode-sdk.d.ts @@ -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 }) => 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; diff --git a/web/src/lib/tinode/topics.ts b/web/src/lib/tinode/topics.ts index 190dc5a9..b958211b 100644 --- a/web/src/lib/tinode/topics.ts +++ b/web/src/lib/tinode/topics.ts @@ -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;