fix: corrige chat reabrindo sozinho e melhora mensagens
- Remove window.show() que forçava chat reabrir a cada polling - Chat só abre minimizado quando há NOVAS mensagens (janela não existia) - Se usuário fechou o chat, não reabre automaticamente - Corrige acentuação: "Voce" → "Você", "nao" → "não" - Simplifica toast para "Chat ao vivo iniciado" - Melhora mensagem de erro quando máquina está offline - Loga erro técnico no console ao invés de exibir para usuário 🤖 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
e66b3cce92
commit
0afdba1635
6 changed files with 33 additions and 16 deletions
|
|
@ -818,26 +818,23 @@ async fn process_chat_update(
|
|||
);
|
||||
|
||||
// Mostrar janela de chat minimizada (menos intrusivo que abrir completo)
|
||||
// Só abre se a janela não existir - se usuário fechou, não reabre automaticamente
|
||||
if let Some(session) = current_sessions.first() {
|
||||
// Abrir janela se nao existir
|
||||
let label = format!("chat-{}", session.ticket_id);
|
||||
if app.get_webview_window(&label).is_none() {
|
||||
let _ = open_chat_window(app, &session.ticket_id);
|
||||
// Minimizar imediatamente apos abrir
|
||||
// Minimizar imediatamente após abrir
|
||||
let _ = set_chat_minimized(app, &session.ticket_id, true);
|
||||
}
|
||||
// Se ja existe, apenas garantir que esta visivel (pode estar escondida)
|
||||
else if let Some(window) = app.get_webview_window(&label) {
|
||||
let _ = window.show();
|
||||
}
|
||||
// Se janela já existe, não força reabrir - respeita decisão do usuário
|
||||
}
|
||||
|
||||
// Notificacao nativa
|
||||
let notification_title = "Nova mensagem de suporte";
|
||||
let notification_body = if new_count == 1 {
|
||||
"Voce recebeu 1 nova mensagem no chat".to_string()
|
||||
"Você recebeu 1 nova mensagem no chat".to_string()
|
||||
} else {
|
||||
format!("Voce recebeu {} novas mensagens no chat", new_count)
|
||||
format!("Você recebeu {} novas mensagens no chat", new_count)
|
||||
};
|
||||
let _ = app
|
||||
.notification()
|
||||
|
|
@ -929,7 +926,7 @@ pub fn minimize_chat_window(app: &tauri::AppHandle, ticket_id: &str) -> Result<(
|
|||
/// Redimensiona a janela de chat para modo minimizado (chip) ou expandido
|
||||
pub fn set_chat_minimized(app: &tauri::AppHandle, ticket_id: &str, minimized: bool) -> Result<(), String> {
|
||||
let label = format!("chat-{}", ticket_id);
|
||||
let window = app.get_webview_window(&label).ok_or("Janela nao encontrada")?;
|
||||
let window = app.get_webview_window(&label).ok_or("Janela não encontrada")?;
|
||||
|
||||
// Tamanhos - chip minimizado com margem extra para badge (absolute -top-1 -right-1)
|
||||
let (width, height) = if minimized {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue