From c7c2b8beaf329c76b9b76f9ed956ea44b6c1a637 Mon Sep 17 00:00:00 2001 From: agavalda Date: Tue, 7 May 2024 12:03:49 +0200 Subject: [PATCH] #149 reload only the profile that is selected --- src-tauri/src/app/handles.rs | 2 +- src-tauri/src/app/menu.rs | 2 +- src/routes/+page.svelte | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/app/handles.rs b/src-tauri/src/app/handles.rs index 09197fe0..2df8a1f0 100644 --- a/src-tauri/src/app/handles.rs +++ b/src-tauri/src/app/handles.rs @@ -411,7 +411,7 @@ fn get_session_and_server(app: &tauri::AppHandle) -> (String, ServerProps) { async fn refresh_profile(app: &tauri::AppHandle) { let (session_id, server_props) = get_session_and_server(app); let _ = refresh_profile_on_server(&server_props, &session_id).await; - app.emit_all("profile_loaded", "") + app.emit_all("profile_loaded", session_id) .expect("Can't emit event to window!"); } diff --git a/src-tauri/src/app/menu.rs b/src-tauri/src/app/menu.rs index 2729d6a0..e4e77738 100644 --- a/src-tauri/src/app/menu.rs +++ b/src-tauri/src/app/menu.rs @@ -97,7 +97,7 @@ pub fn handle_menu_event(event: WindowMenuEvent) { } if internal_state.session_id.is_some() { window - .emit("profile_loaded", "") + .emit("profile_loaded", &internal_state.session_id) .expect("Can't emit event to window!"); } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 432be856..517f2b7c 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -16,8 +16,8 @@ $: isLoading = $loading; $: sessions = []; - listen('profile_loaded', () => { - if (selectedSession) { + listen('profile_loaded', (event) => { + if (selectedSession && selectedSession.id === event.payload) { reloadProfile(selectedSession); } });