Reset desktop chat unread badge when opened

This commit is contained in:
rever-tecnologia 2025-12-09 16:46:53 -03:00
parent 2ea0952f16
commit 58319ec0f9

View file

@ -107,6 +107,7 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) {
const unreadIds = payload.messages.filter(m => !m.isFromMachine).map(m => m.id as string) const unreadIds = payload.messages.filter(m => !m.isFromMachine).map(m => m.id as string)
if (unreadIds.length > 0) { if (unreadIds.length > 0) {
markMachineMessagesRead(ticketId, unreadIds).catch(err => console.error("mark read falhou", err)) markMachineMessagesRead(ticketId, unreadIds).catch(err => console.error("mark read falhou", err))
setUnreadCount(0)
} }
}, },
(err) => { (err) => {
@ -218,6 +219,7 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) {
const handleExpand = async () => { const handleExpand = async () => {
setIsMinimized(false) setIsMinimized(false)
setUnreadCount(0)
try { try {
await invoke("set_chat_minimized", { ticketId, minimized: false }) await invoke("set_chat_minimized", { ticketId, minimized: false })
} catch (err) { } catch (err) {