From d8d8617a6c6afb44e706f99a433dce7c5136e875 Mon Sep 17 00:00:00 2001 From: VPS 4 Builder Date: Mon, 6 Jul 2026 22:24:05 +0200 Subject: [PATCH] =?UTF-8?q?fix(wa-inbox):=20esvazia=20a=20lista=20de=20cha?= =?UTF-8?q?ts=20quando=20n=C3=A3o=20h=C3=A1=20inst=C3=A2ncia=20ativa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complementa o fix anterior: no mount, loadChats podia rodar com o activeInstanceId persistido (stale) antes de loadInstances validar, deixando os chats na tela mesmo após o reset. Agora o efeito faz setChats([]) quando não há instância ativa. Co-Authored-By: Claude Opus 4.8 --- frontend/views/newwhats/hooks/inbox/useNewInboxBridge.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/views/newwhats/hooks/inbox/useNewInboxBridge.ts b/frontend/views/newwhats/hooks/inbox/useNewInboxBridge.ts index 284bcec..0fce290 100644 --- a/frontend/views/newwhats/hooks/inbox/useNewInboxBridge.ts +++ b/frontend/views/newwhats/hooks/inbox/useNewInboxBridge.ts @@ -61,7 +61,7 @@ function chatToLegacy(c: ReturnType['chats'][0]): is_pinned: c.isPinned, is_archived: c.isArchived, bot_paused: c.botPaused ?? null, - labels: [], + labels: (c as any).labels ?? [], } } @@ -88,6 +88,7 @@ function messagesToLegacy(msgs: ReturnType['messag quoted_message_text: m.replyTo?.body ?? null, quoted_participant: m.replyTo ? (m.replyTo.fromMe ? 'me' : null) : null, participant: m.pushName ?? null, + reactions: m.reactions ?? null, senderJid: m.senderJid ?? null, sender_jid: m.senderJid ?? null, remote_jid: m.chatId, @@ -118,7 +119,9 @@ export function useNewInboxBridge() { // ── Carregar chats quando instância ativa muda ───────────────────────────── useEffect(() => { const { activeInstanceId } = instanceStore - if (!activeInstanceId) return + // Sem instância ativa (ex.: superadmin, ou instância resetada por não ser + // acessível) → esvazia a lista para NÃO deixar chats de outra sessão na tela. + if (!activeInstanceId) { chatStore.setChats([]); return } chatStore.loadChats(activeInstanceId) socketService.joinInstance(activeInstanceId) // Reconcilia nomes em background (cache 30min — leve em escala)