fixed app stuff in frontend

This commit is contained in:
user
2026-03-28 20:35:26 +02:00
parent 7c210ffe8f
commit 49ff819cb5
3 changed files with 30 additions and 8 deletions

View File

@@ -39,6 +39,7 @@ class DeviceDetailsViewModel {
device = $state<DeviceForUI | null>(null);
loading = $state(false);
currentId = $state<number | null>(null);
private _deviceQuery: ReturnType<typeof getDeviceByIdSQ> | null = null;
get streamUrl(): string | null {
if (!this.device) return null;
@@ -50,7 +51,15 @@ class DeviceDetailsViewModel {
this.currentId = id;
try {
const result = await getDeviceByIdSQ({ id });
const query = getDeviceByIdSQ({ id });
if (query.ready) {
await query.refresh();
}
const result = query.ready ? query.current : await query;
this._deviceQuery = query;
if (result?.error || !result?.data) {
this.device = null;
toast.error(result?.error?.message || "Failed to fetch device", {