fix: waveform not rendering on voice messages after thread switch

The call wave sync watcher fired before DOM was updated (flush: 'pre'),
so ref callbacks hadn't registered host elements yet. Changed to
flush: 'post' so WaveSurfer instances are created after DOM refs exist.
Also fixed getCallItem to read from clientTimelineItems (source of truth)
instead of visibleThreadItems which could be stale.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ruslan Bakiev
2026-02-25 08:17:17 +07:00
parent 6e3763a5fd
commit 9b6e8291fe

View File

@@ -588,7 +588,7 @@ const threadStreamItems = computed(() => {
return rows.sort((a, b) => a.at.localeCompare(b.at)); return rows.sort((a, b) => a.at.localeCompare(b.at));
}); });
// Sync call waves when thread stream changes // Sync call waves when thread stream changes (flush: 'post' ensures DOM refs are registered)
watch( watch(
() => threadStreamItems.value.map((entry: any) => `${entry.kind}:${entry.id}`).join("|"), () => threadStreamItems.value.map((entry: any) => `${entry.kind}:${entry.id}`).join("|"),
() => { () => {
@@ -597,10 +597,15 @@ watch(
.filter((entry: any) => entry.kind === "call") .filter((entry: any) => entry.kind === "call")
.map((entry: any) => entry.item.id as string), .map((entry: any) => entry.item.id as string),
); );
const getCallItem = (id: string) => const getCallItem = (id: string) => {
visibleThreadItems.value.find((item) => item.id === id && item.kind === "call"); const timelineItem = clientTimelineItems.value.find(
(entry) => entry.contentType === "message" && entry.message?.id === id && entry.message?.kind === "call",
);
return timelineItem?.message ?? undefined;
};
void _syncCommCallWavesRaw(activeCallIds, getCallItem); void _syncCommCallWavesRaw(activeCallIds, getCallItem);
}, },
{ flush: "post" },
); );
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------