feat: remove CommunicationsQuery, load messages on-demand only

- Remove bulk CommunicationsQuery from useContacts (was loading ALL
  messages for ALL contacts on init)
- Rebuild commThreads from contacts + contactInboxes using the new
  lastMessageText field from Phase 1
- Per-contact messages now load on-demand via getClientTimeline
- Remove commItems from useWorkspaceRouting, use clientTimelineItems

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ruslan Bakiev
2026-02-24 20:02:58 +07:00
parent 601de37ab0
commit ac9c50b47d
3 changed files with 28 additions and 75 deletions

View File

@@ -31,7 +31,7 @@ export function useWorkspaceRouting(opts: {
commThreads: ComputedRef<{ id: string; [key: string]: any }[]>;
contacts: Ref<{ id: string; name: string; [key: string]: any }[]>;
deals: Ref<{ id: string; contact: string; [key: string]: any }[]>;
commItems: Ref<{ id: string; contact: string; [key: string]: any }[]>;
clientTimelineItems: Ref<{ id: string; contactId: string; contentType: string; message?: { contact: string } | null; [key: string]: any }[]>;
activeChangeMessage: ComputedRef<{ changeSetId?: string | null; changeItems?: PilotChangeItem[] | null } | null>;
activeChangeItem: ComputedRef<PilotChangeItem | null>;
activeChangeItems: ComputedRef<PilotChangeItem[]>;
@@ -340,9 +340,9 @@ export function useWorkspaceRouting(opts: {
if (item.entity === "message" && item.entityId) {
opts.peopleLeftMode.value = "contacts";
opts.peopleListMode.value = "contacts";
const message = opts.commItems.value.find((entry) => entry.id === item.entityId);
if (message?.contact) {
opts.openCommunicationThread(message.contact);
const timelineEntry = opts.clientTimelineItems.value.find((entry) => entry.contentType === "message" && entry.message && entry.id === item.entityId);
if (timelineEntry?.message?.contact) {
opts.openCommunicationThread(timelineEntry.message.contact);
}
opts.focusedCalendarEventId.value = "";
syncPathFromUi(push);