refactor(control): improve code structure through new function

This commit is contained in:
E44
2026-01-19 23:35:38 +01:00
parent c7bf6fa6f7
commit 1138842269
+12 -10
View File
@@ -29,14 +29,18 @@ export async function change_file_path(new_path: string) {
const displays = await db.displays.toArray(); const displays = await db.displays.toArray();
for (const display of displays) { for (const display of displays) {
const changed_paths = await get_changed_directory_paths(display, new_path); await update_changed_directories(display, new_path);
if (!changed_paths) continue; }
}
async function update_changed_directories(display: Display, path: string = '/') {
const changed_paths = await get_changed_directory_paths(display, path);
if (!changed_paths) return;
console.debug('Update file system from', display.name, ':', changed_paths); console.debug('Update file system from', display.name, ':', changed_paths);
for (const path of changed_paths) { for (const path of changed_paths) {
await update_folder_elements_recursively(display, path); await update_folder_elements_recursively(display, path);
} }
} }
}
export async function delete_and_deselect_unique_files_from_display(display_id: string) { export async function delete_and_deselect_unique_files_from_display(display_id: string) {
const files_on_display = await db.files_on_display const files_on_display = await db.files_on_display
@@ -94,7 +98,10 @@ export async function update_current_folder_on_selected_displays() {
}); });
const current_path = get(current_file_path); const current_path = get(current_file_path);
for (const display of await db.displays.where('id').anyOf(get(selected_online_display_ids)).toArray()) { for (const display of await db.displays
.where('id')
.anyOf(get(selected_online_display_ids))
.toArray()) {
await update_folder_elements_recursively(display, current_path); await update_folder_elements_recursively(display, current_path);
} }
} }
@@ -415,12 +422,7 @@ export async function create_path_on_all_selected_displays(
} }
setTimeout(async () => { setTimeout(async () => {
for (const display of displays_without_path) { for (const display of displays_without_path) {
const changed_paths = await get_changed_directory_paths(display, '/'); await update_changed_directories(display);
if (!changed_paths) continue;
console.debug('Update file system from', display.name, ':', changed_paths);
for (const path of changed_paths) {
await update_folder_elements_recursively(display, path);
}
} }
}, 0); }, 0);
} }