fixed app stuff in frontend
This commit is contained in:
@@ -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", {
|
||||
|
||||
Reference in New Issue
Block a user