feat: melhorias visuais na janela de chat do desktop
- Desabilita sombra da janela para transparência funcionar corretamente - Adiciona badge de mensagens não lidas no chip minimizado - Ajusta tamanho da janela minimizada para acomodar badge e texto offline - Mostra chat minimizado com badge quando há novas mensagens (menos intrusivo) - Adiciona listener para atualização de unread count em tempo real 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
24dee5d5eb
commit
d2b8c27206
2 changed files with 44 additions and 8 deletions
|
|
@ -49,6 +49,7 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
|
|||
const [hasSession, setHasSession] = useState(false)
|
||||
const [pendingAttachments, setPendingAttachments] = useState<UploadedAttachment[]>([])
|
||||
const [isMinimized, setIsMinimized] = useState(false)
|
||||
const [unreadCount, setUnreadCount] = useState(0)
|
||||
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null)
|
||||
const lastFetchRef = useRef<number>(0)
|
||||
|
|
@ -186,7 +187,7 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
|
|||
init()
|
||||
|
||||
// Listener para eventos de nova mensagem do Tauri
|
||||
const unlistenPromise = listen<{ ticketId: string; message: ChatMessage }>(
|
||||
const unlistenNewMessage = listen<{ ticketId: string; message: ChatMessage }>(
|
||||
"raven://chat/new-message",
|
||||
(event) => {
|
||||
if (event.payload.ticketId === ticketId) {
|
||||
|
|
@ -202,12 +203,25 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
|
|||
}
|
||||
)
|
||||
|
||||
// Listener para atualização de mensagens não lidas
|
||||
const unlistenUnread = listen<{ totalUnread: number; sessions: Array<{ ticketId: string; unreadCount: number }> }>(
|
||||
"raven://chat/unread-update",
|
||||
(event) => {
|
||||
// Encontrar o unread count para este ticket
|
||||
const session = event.payload.sessions?.find(s => s.ticketId === ticketId)
|
||||
if (session) {
|
||||
setUnreadCount(session.unreadCount ?? 0)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return () => {
|
||||
mounted = false
|
||||
if (pollIntervalRef.current) {
|
||||
clearInterval(pollIntervalRef.current)
|
||||
}
|
||||
unlistenPromise.then(unlisten => unlisten())
|
||||
unlistenNewMessage.then(unlisten => unlisten())
|
||||
unlistenUnread.then(unlisten => unlisten())
|
||||
}
|
||||
}, [ticketId, loadConfig, fetchMessages, fetchSessionInfo])
|
||||
|
||||
|
|
@ -378,7 +392,7 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
|
|||
<div className="flex h-full w-full items-end justify-end bg-transparent">
|
||||
<button
|
||||
onClick={handleExpand}
|
||||
className="flex items-center gap-2 rounded-full bg-black px-4 py-2 text-white shadow-lg hover:bg-black/90"
|
||||
className="relative flex items-center gap-2 rounded-full bg-black px-4 py-2 text-white shadow-lg hover:bg-black/90"
|
||||
>
|
||||
<MessageCircle className="size-4" />
|
||||
<span className="text-sm font-medium">
|
||||
|
|
@ -386,6 +400,12 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
|
|||
</span>
|
||||
<span className="size-2 rounded-full bg-emerald-400" />
|
||||
<ChevronUp className="size-4" />
|
||||
{/* Badge de mensagens não lidas */}
|
||||
{unreadCount > 0 && (
|
||||
<span className="absolute -right-1 -top-1 flex size-5 items-center justify-center rounded-full bg-red-500 text-xs font-bold">
|
||||
{unreadCount > 9 ? "9+" : unreadCount}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue