aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/stores/ui.svelte.ts
blob: 8fc339b9776f82a5a2cf41f3fae233414746fd6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
export class UIState {
  currentView = $state("home");
  status = $state("Ready");
  showConsole = $state(false);
  appVersion = $state("...");
  
  private statusTimeout: any;

  constructor() {
    // Watch for status changes to auto-dismiss
    $effect(() => {
        if (this.status !== "Ready") {
            if (this.statusTimeout) clearTimeout(this.statusTimeout);
            this.statusTimeout = setTimeout(() => {
                this.status = "Ready";
            }, 5000);
        }
    });
  }

  setStatus(msg: string) {
    this.status = msg;
  }

  toggleConsole() {
    this.showConsole = !this.showConsole;
  }

  setView(view: string) {
    this.currentView = view;
  }
}

export const uiState = new UIState();