fix: corrige multiplos problemas de chat e infra
- stack.yml: reduz replicas web para 1 (SQLite nao suporta escrita concorrente) - chat.rs: janela de chat ja abre minimizada para evitar marcar mensagens como lidas prematuramente - rustdesk.rs: preserva ID existente do RustDesk ao reprovisionar (evita criar novo ID a cada reinstalacao do Raven) - ChatWidget.tsx: remove isMinimized das dependencias do useEffect para evitar memory leak de resubscriptions 🤖 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
695a44781a
commit
fb97d9bec8
4 changed files with 80 additions and 34 deletions
|
|
@ -675,14 +675,16 @@ async fn process_chat_update(
|
|||
);
|
||||
|
||||
// Mostrar janela de chat minimizada (menos intrusivo que abrir completo)
|
||||
// A janela ja abre minimizada por padrao (start_minimized=true)
|
||||
if let Some(session) = current_sessions.first() {
|
||||
let label = format!("chat-{}", session.ticket_id);
|
||||
if let Some(window) = app.get_webview_window(&label) {
|
||||
// Janela ja existe - apenas mostrar e garantir que esta minimizada
|
||||
let _ = window.show();
|
||||
let _ = set_chat_minimized(app, &session.ticket_id, true);
|
||||
} else {
|
||||
// Criar nova janela ja minimizada (sem necessidade de chamar set_chat_minimized depois)
|
||||
let _ = open_chat_window(app, &session.ticket_id, session.ticket_ref);
|
||||
let _ = set_chat_minimized(app, &session.ticket_id, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -707,6 +709,11 @@ async fn process_chat_update(
|
|||
// ============================================================================
|
||||
|
||||
fn open_chat_window_internal(app: &tauri::AppHandle, ticket_id: &str, ticket_ref: u64) -> Result<(), String> {
|
||||
open_chat_window_with_state(app, ticket_id, ticket_ref, true) // Por padrao abre minimizada
|
||||
}
|
||||
|
||||
/// Abre janela de chat com estado inicial de minimizacao configuravel
|
||||
fn open_chat_window_with_state(app: &tauri::AppHandle, ticket_id: &str, ticket_ref: u64, start_minimized: bool) -> Result<(), String> {
|
||||
let label = format!("chat-{}", ticket_id);
|
||||
|
||||
// Verificar se ja existe
|
||||
|
|
@ -716,6 +723,13 @@ fn open_chat_window_internal(app: &tauri::AppHandle, ticket_id: &str, ticket_ref
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
// Dimensoes baseadas no estado inicial
|
||||
let (width, height) = if start_minimized {
|
||||
(240.0, 52.0) // Tamanho minimizado (chip com badge)
|
||||
} else {
|
||||
(380.0, 520.0) // Tamanho expandido
|
||||
};
|
||||
|
||||
// Obter tamanho da tela para posicionar no canto inferior direito
|
||||
let monitors = app.available_monitors().map_err(|e| e.to_string())?;
|
||||
let primary = monitors.into_iter().next();
|
||||
|
|
@ -723,8 +737,6 @@ fn open_chat_window_internal(app: &tauri::AppHandle, ticket_id: &str, ticket_ref
|
|||
let (x, y) = if let Some(monitor) = primary {
|
||||
let size = monitor.size();
|
||||
let scale = monitor.scale_factor();
|
||||
let width = 380.0;
|
||||
let height = 520.0;
|
||||
let margin = 20.0;
|
||||
let taskbar_height = 50.0;
|
||||
(
|
||||
|
|
@ -744,7 +756,7 @@ fn open_chat_window_internal(app: &tauri::AppHandle, ticket_id: &str, ticket_ref
|
|||
WebviewUrl::App(url_path.into()),
|
||||
)
|
||||
.title("Chat de Suporte")
|
||||
.inner_size(380.0, 520.0)
|
||||
.inner_size(width, height) // Abre ja no tamanho correto
|
||||
.min_inner_size(240.0, 52.0) // Tamanho minimo para modo minimizado com badge
|
||||
.position(x, y)
|
||||
.decorations(false) // Sem decoracoes nativas - usa header customizado
|
||||
|
|
@ -757,7 +769,7 @@ fn open_chat_window_internal(app: &tauri::AppHandle, ticket_id: &str, ticket_ref
|
|||
.build()
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
crate::log_info!("Janela de chat aberta: {}", label);
|
||||
crate::log_info!("Janela de chat aberta (minimizada={}): {}", start_minimized, label);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue