fix(desktop): corrige parâmetros invoke para snake_case no Tauri 2
Tauri 2 espera parâmetros em snake_case nos comandos Rust. Corrigido: ticketId -> ticket_id, ticketRef -> ticket_ref, etc. 🤖 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
915ca6d8ff
commit
3b6b9dfeac
3 changed files with 13 additions and 12 deletions
|
|
@ -103,7 +103,8 @@ export function ChatHubWidget() {
|
||||||
console.log("[ChatHub] Selecionando sessao:", { ticketId, ticketRef })
|
console.log("[ChatHub] Selecionando sessao:", { ticketId, ticketRef })
|
||||||
try {
|
try {
|
||||||
console.log("[ChatHub] Chamando invoke open_chat_window...")
|
console.log("[ChatHub] Chamando invoke open_chat_window...")
|
||||||
const result = await invoke("open_chat_window", { ticketId, ticketRef })
|
// Tauri 2 espera snake_case nos parametros
|
||||||
|
const result = await invoke("open_chat_window", { ticket_id: ticketId, ticket_ref: ticketRef })
|
||||||
console.log("[ChatHub] Janela aberta com sucesso, result:", result)
|
console.log("[ChatHub] Janela aberta com sucesso, result:", result)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("[ChatHub] ERRO ao abrir janela de chat:", err)
|
console.error("[ChatHub] ERRO ao abrir janela de chat:", err)
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const prevHasSession = prevHasSessionRef.current
|
const prevHasSession = prevHasSessionRef.current
|
||||||
if (prevHasSession && !hasSession) {
|
if (prevHasSession && !hasSession) {
|
||||||
invoke("close_chat_window", { ticketId }).catch((err) => {
|
invoke("close_chat_window", { ticket_id: ticketId }).catch((err) => {
|
||||||
console.error("Erro ao fechar janela ao encerrar sessão:", err)
|
console.error("Erro ao fechar janela ao encerrar sessão:", err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -405,10 +405,10 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) {
|
||||||
|
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
await invoke("mark_chat_messages_read", {
|
await invoke("mark_chat_messages_read", {
|
||||||
baseUrl: cfg.apiBaseUrl,
|
base_url: cfg.apiBaseUrl,
|
||||||
token: cfg.token,
|
token: cfg.token,
|
||||||
ticketId,
|
ticket_id: ticketId,
|
||||||
messageIds: chunk,
|
message_ids: chunk,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -657,9 +657,9 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) {
|
||||||
const bodyToSend = messageText
|
const bodyToSend = messageText
|
||||||
const cfg = await ensureConfig()
|
const cfg = await ensureConfig()
|
||||||
await invoke("send_chat_message", {
|
await invoke("send_chat_message", {
|
||||||
baseUrl: cfg.apiBaseUrl,
|
base_url: cfg.apiBaseUrl,
|
||||||
token: cfg.token,
|
token: cfg.token,
|
||||||
ticketId,
|
ticket_id: ticketId,
|
||||||
body: bodyToSend,
|
body: bodyToSend,
|
||||||
attachments: attachmentsToSend.length > 0 ? attachmentsToSend : undefined,
|
attachments: attachmentsToSend.length > 0 ? attachmentsToSend : undefined,
|
||||||
})
|
})
|
||||||
|
|
@ -692,7 +692,7 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) {
|
||||||
const handleMinimize = async () => {
|
const handleMinimize = async () => {
|
||||||
setIsMinimized(true)
|
setIsMinimized(true)
|
||||||
try {
|
try {
|
||||||
await invoke("set_chat_minimized", { ticketId, minimized: true })
|
await invoke("set_chat_minimized", { ticket_id: ticketId, minimized: true })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Erro ao minimizar janela:", err)
|
console.error("Erro ao minimizar janela:", err)
|
||||||
}
|
}
|
||||||
|
|
@ -707,14 +707,14 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) {
|
||||||
|
|
||||||
setIsMinimized(false)
|
setIsMinimized(false)
|
||||||
try {
|
try {
|
||||||
await invoke("set_chat_minimized", { ticketId, minimized: false })
|
await invoke("set_chat_minimized", { ticket_id: ticketId, minimized: false })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Erro ao expandir janela:", err)
|
console.error("Erro ao expandir janela:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
invoke("close_chat_window", { ticketId })
|
invoke("close_chat_window", { ticket_id: ticketId })
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||||
|
|
|
||||||
|
|
@ -1101,9 +1101,9 @@ const resolvedAppUrl = useMemo(() => {
|
||||||
// Abre/minimiza chat quando aparecem novas não lidas
|
// Abre/minimiza chat quando aparecem novas não lidas
|
||||||
if (hasSessions && totalUnread > prevUnread) {
|
if (hasSessions && totalUnread > prevUnread) {
|
||||||
const session = payload.sessions[0]
|
const session = payload.sessions[0]
|
||||||
invoke("open_chat_window", { ticketId: session.ticketId, ticketRef: session.ticketRef }).catch(console.error)
|
invoke("open_chat_window", { ticket_id: session.ticketId, ticket_ref: session.ticketRef }).catch(console.error)
|
||||||
// Minimiza para não ser intrusivo
|
// Minimiza para não ser intrusivo
|
||||||
invoke("set_chat_minimized", { ticketId: session.ticketId, minimized: true }).catch(console.error)
|
invoke("set_chat_minimized", { ticket_id: session.ticketId, minimized: true }).catch(console.error)
|
||||||
}
|
}
|
||||||
|
|
||||||
prevUnread = totalUnread
|
prevUnread = totalUnread
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue