Files
automatic/ui/dynamicUI.ts
T
Vladimir Mandic 34d9d304db modular guiders and other stuff
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-08-30 11:51:19 +02:00

26 lines
588 B
TypeScript

import { log } from './logger';
import { authFetch } from './authWrap';
interface Model {
type: string;
class: string;
checkpoint: string;
title: string;
name: string;
}
let lastCheckpoint = '';
async function updateUI(model: Model) {
if (model.checkpoint === lastCheckpoint) return;
lastCheckpoint = model.checkpoint;
log('modelUpdate', model);
}
export async function updateModel() {
const req = await authFetch(`${window.api}/checkpoint`);
if (req && req.ok) {
const model = await req.json() as Model;
if (model?.type?.length > 0) updateUI(model);
}
}