fix(control): add error handler for shutdown

closes: #53
This commit is contained in:
E44
2026-06-14 19:09:20 +02:00
parent 5ecf2da8a9
commit 2dcf5a7758
2 changed files with 13 additions and 8 deletions
+6 -2
View File
@@ -325,8 +325,12 @@ async function run_shell_command(ip: string, command: string): Promise<RequestRe
return await request_display(ip, '/shellCommand', options); return await request_display(ip, '/shellCommand', options);
} }
export async function shutdown(ip: string): Promise<RequestResponse> { export async function shutdown(ip: string): Promise<boolean> {
return await run_shell_command(ip, 'xfce4-session-logout --halt'); 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<RequestResponse> { export async function startup(mac: string): Promise<RequestResponse> {
@@ -114,12 +114,13 @@
async function shutdown_action() { async function shutdown_action() {
popup_content.open = false; popup_content.open = false;
await run_on_all_selected_displays((d) => { await run_on_all_selected_displays(async (d) => {
shutdown(d.ip); // no await here because we want to be fast if (await shutdown(d.ip)) {
db.displays.update(d.id, { db.displays.update(d.id, {
status: 'app_offline', status: 'app_offline',
preview: { currently_updating: false, url: null } preview: { currently_updating: false, url: null }
}); });
}
}, false); }, false);
} }