From 2dcf5a77585c4ad0e4486ae199ef2b5e315b2a68 Mon Sep 17 00:00:00 2001 From: E44 <129310925+programmer-44@users.noreply.github.com> Date: Sun, 14 Jun 2026 19:09:20 +0200 Subject: [PATCH] fix(control): add error handler for shutdown closes: #53 --- control/frontend/src/lib/ts/api_handler.ts | 8 ++++++-- control/frontend/src/routes/ControlView.svelte | 13 +++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/control/frontend/src/lib/ts/api_handler.ts b/control/frontend/src/lib/ts/api_handler.ts index d567273..f4a6205 100755 --- a/control/frontend/src/lib/ts/api_handler.ts +++ b/control/frontend/src/lib/ts/api_handler.ts @@ -325,8 +325,12 @@ async function run_shell_command(ip: string, command: string): Promise { - return await run_shell_command(ip, 'xfce4-session-logout --halt'); +export async function shutdown(ip: string): Promise { + const command = 'xfce4-session-logout --halt'; + const raw_response = await run_shell_command(ip, command); + if (!raw_response.ok) return false; + if (handle_shell_error(ip, raw_response, command, true)) return false; + return true; } export async function startup(mac: string): Promise { diff --git a/control/frontend/src/routes/ControlView.svelte b/control/frontend/src/routes/ControlView.svelte index 2ebb172..6fd29ab 100644 --- a/control/frontend/src/routes/ControlView.svelte +++ b/control/frontend/src/routes/ControlView.svelte @@ -114,12 +114,13 @@ async function shutdown_action() { popup_content.open = false; - await run_on_all_selected_displays((d) => { - shutdown(d.ip); // no await here because we want to be fast - db.displays.update(d.id, { - status: 'app_offline', - preview: { currently_updating: false, url: null } - }); + await run_on_all_selected_displays(async (d) => { + if (await shutdown(d.ip)) { + db.displays.update(d.id, { + status: 'app_offline', + preview: { currently_updating: false, url: null } + }); + } }, false); }