mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 00:47:09 +00:00
chore(control/run_on_all_selected_displays): parallel processing
This commit is contained in:
@@ -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[]> {
|
||||||
|
|||||||
Reference in New Issue
Block a user