mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-05 16:37:09 +00:00
@@ -1,8 +1,8 @@
|
|||||||
import { screenshot_loop } from './stores/displays';
|
import { screenshot_loop } from './stores/displays';
|
||||||
import { ping_ip } from './api_handler';
|
import { ping_ip } from './api_handler';
|
||||||
import type { Display, DisplayStatus } from './types';
|
import type { Display, DisplayStatus } from './types';
|
||||||
import { update_folder_elements_recursively } from './stores/files';
|
|
||||||
import { db } from './database';
|
import { db } from './database';
|
||||||
|
import { update_changed_directories } from './stores/files';
|
||||||
|
|
||||||
const update_display_status_interval_seconds = 20;
|
const update_display_status_interval_seconds = 20;
|
||||||
const update_display_loading_status_interval_seconds = 2;
|
const update_display_loading_status_interval_seconds = 2;
|
||||||
@@ -10,8 +10,6 @@ const update_display_loading_status_interval_seconds = 2;
|
|||||||
const loading_display_ids: string[] = [];
|
const loading_display_ids: string[] = [];
|
||||||
|
|
||||||
export async function on_app_start() {
|
export async function on_app_start() {
|
||||||
await db.files.clear();
|
|
||||||
await db.files_on_display.clear();
|
|
||||||
await db.displays
|
await db.displays
|
||||||
.toCollection()
|
.toCollection()
|
||||||
.modify({ status: null, preview: { currently_updating: false, url: null } });
|
.modify({ status: null, preview: { currently_updating: false, url: null } });
|
||||||
@@ -47,17 +45,19 @@ export async function update_display_status(display: Display): Promise<DisplaySt
|
|||||||
}
|
}
|
||||||
if (resp.status === null && display.status !== null) return null;
|
if (resp.status === null && display.status !== null) return null;
|
||||||
if (resp.status !== display.status) {
|
if (resp.status !== display.status) {
|
||||||
|
let run_on_display_start = false;
|
||||||
// status change
|
// status change
|
||||||
if (resp.status === 'app_offline') {
|
if (resp.status === 'app_offline') {
|
||||||
loading_display_ids.push(display.id);
|
loading_display_ids.push(display.id);
|
||||||
} else {
|
} else {
|
||||||
remove_display_from_loading_displays(display.id);
|
remove_display_from_loading_displays(display.id);
|
||||||
if (resp.status === 'app_online') {
|
if (resp.status === 'app_online') {
|
||||||
on_display_start(display);
|
run_on_display_start = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
display.status = resp.status;
|
display.status = resp.status;
|
||||||
await db.displays.put(display); // save
|
await db.displays.put(display); // save
|
||||||
|
if (run_on_display_start) await on_display_start(display);
|
||||||
}
|
}
|
||||||
return resp.status;
|
return resp.status;
|
||||||
}
|
}
|
||||||
@@ -70,6 +70,6 @@ export function remove_display_from_loading_displays(display_id: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function on_display_start(display: Display) {
|
async function on_display_start(display: Display) {
|
||||||
await update_folder_elements_recursively(display, '/');
|
await update_changed_directories(display);
|
||||||
screenshot_loop(display.id);
|
screenshot_loop(display.id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export async function change_file_path(new_path: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update_changed_directories(display: Display, path: string = '/') {
|
export async function update_changed_directories(display: Display, path: string = '/') {
|
||||||
const changed_paths = await get_changed_directory_paths(display, path);
|
const changed_paths = await get_changed_directory_paths(display, path);
|
||||||
if (!changed_paths) return;
|
if (!changed_paths) return;
|
||||||
console.debug('Update file system from', display.name, ':', changed_paths);
|
console.debug('Update file system from', display.name, ':', changed_paths);
|
||||||
@@ -239,7 +239,7 @@ async function get_recursive_changed_directory_paths(
|
|||||||
return has_changed;
|
return has_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function update_folder_elements_recursively(
|
async function update_folder_elements_recursively(
|
||||||
display: Display,
|
display: Display,
|
||||||
file_path: string = '/'
|
file_path: string = '/'
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user