feat(web): refresh simulator dashboard UI
This commit is contained in:
@@ -805,39 +805,6 @@ const stopPolling = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const pollClientData = async () => {
|
||||
const { device } = getAppState();
|
||||
if (!device || device.role !== 'client') return;
|
||||
|
||||
const [recs, links, deviceList, notifications] = await Promise.all([
|
||||
api.ops.listRecordings().catch(() => ({ recordings: [] })),
|
||||
api.devices.listLinks().catch(() => ({ links: [] })),
|
||||
api.devices.list().catch(() => ({ devices: [] })),
|
||||
api.ops.listNotifications().catch(() => ({ notifications: [] }))
|
||||
]);
|
||||
|
||||
const cameraById = new Map(
|
||||
(deviceList.devices || [])
|
||||
.filter((entry) => entry.role === 'camera')
|
||||
.map((entry) => [entry.id, entry])
|
||||
);
|
||||
|
||||
const linkedCameras = (links.links || []).map((link) => {
|
||||
const camera = cameraById.get(link.cameraDeviceId);
|
||||
return {
|
||||
...link,
|
||||
cameraName: camera?.name ?? null,
|
||||
cameraStatus: camera?.status ?? 'offline'
|
||||
};
|
||||
});
|
||||
|
||||
setAppState({
|
||||
recordings: recs.recordings || [],
|
||||
linkedCameras
|
||||
});
|
||||
syncMotionNotificationsFromDeliveries(notifications.notifications);
|
||||
};
|
||||
|
||||
const startPolling = () => {
|
||||
stopPolling();
|
||||
void pollClientData();
|
||||
|
||||
Reference in New Issue
Block a user