diff --git a/package-lock.json b/package-lock.json index 14c6369..5272f7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1030,7 +1030,7 @@ "node_modules/@insignia/iios-messaging-ui": { "version": "0.1.0", "resolved": "file:../iios/packages/iios-messaging-ui/insignia-iios-messaging-ui-0.1.0.tgz", - "integrity": "sha512-Ks+tTnNBw3QqNpBlggEnbmfRrDnCSq9jq3b5TOsc/XEEgzdebtFDuQziVW/G6oRp4ysTQ6Fci/XRm1z1yLf4Wg==", + "integrity": "sha512-sfNRRJQgbq3FCvwUtn4H7ojHnhQZnM5bd2MQmq3XFmTZNsj0BGNh/dcKvR9/7vbLaXP10kuOHZGXrCi/1LsJYA==", "peerDependencies": { "@insignia/iios-kernel-client": "*", "react": ">=18", diff --git a/src/lib/crm-messaging-adapter.ts b/src/lib/crm-messaging-adapter.ts index 0ecb00e..f85b1ef 100644 --- a/src/lib/crm-messaging-adapter.ts +++ b/src/lib/crm-messaging-adapter.ts @@ -81,7 +81,7 @@ export class CrmMessagingAdapter implements MessagingAdapter { async listConversations(): Promise { const [convs, names] = await Promise.all([ this.sdk.query("crm.messenger.conversation.list", {}), - this.directory(), + this.directoryMap(), ]); return convs.map((c) => this.toConversation(c, names)); } @@ -219,11 +219,16 @@ export class CrmMessagingAdapter implements MessagingAdapter { poll.timer = setInterval(tick, POLL_MS); } + /** The org directory — people you can start a DM/group with. Drives the "New message" picker. */ + async directory(): Promise { + const dir = await this.sdk.query("crm.messenger.directory", { kind: "all", limit: 200 }); + return dir.map((d) => ({ id: d.id, name: d.displayName, kind: d.kind })); + } + // ── mapping ──────────────────────────────────────────────────── - private async directory(): Promise> { + private async directoryMap(): Promise> { if (!this.names) { - const dir = await this.sdk.query("crm.messenger.directory", { kind: "all", limit: 200 }); - this.names = new Map(dir.map((d) => [d.id, d.displayName])); + this.names = new Map((await this.directory()).map((p) => [p.id, p.name])); } return this.names; }