chore(control/run_on_all_selected_displays): parallel processing

This commit is contained in:
2026-01-06 19:58:24 +01:00
parent 0614746d95
commit 46e59d35bf
+12 -5
View File
@@ -147,14 +147,21 @@ export async function run_on_all_selected_displays(
update_screenshot_afterwards: boolean = true, update_screenshot_afterwards: boolean = true,
ignore_offline: boolean = true ignore_offline: boolean = true
) { ) {
for (const display_id of get(selected_display_ids)) { const maybe_displays: (Display | null)[] = await Promise.all(
const display = await get_display_by_id(display_id); // fails when only a single promis fails
if (!display || (ignore_offline && display.status === 'host_offline')) continue; get(selected_display_ids).map(async (id) => await get_display_by_id(id))
);
const displays: Display[] = maybe_displays.filter((d): d is Display => d !== null);
Promise.all(
displays.map(async (display) => {
if (!display || (ignore_offline && display.status === 'host_offline')) return;
await run_function(display); await run_function(display);
if (update_screenshot_afterwards) { if (update_screenshot_afterwards) {
await screenshot_loop(display_id); await screenshot_loop(display.id);
}
} }
})
);
} }
export async function get_display_groups(): Promise<DisplayGroup[]> { export async function get_display_groups(): Promise<DisplayGroup[]> {