mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-05 16:37:09 +00:00
refactor(control): improve code structure through new function
This commit is contained in:
@@ -29,13 +29,17 @@ 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) {
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user