From 64b939e6ac0b196d18ee183a37a40b0bf7927a80 Mon Sep 17 00:00:00 2001 From: Natsuu Date: Wed, 14 Jan 2026 03:41:18 +0000 Subject: refactor: split App.svelte into components --- ui/src/stores/ui.svelte.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 ui/src/stores/ui.svelte.ts (limited to 'ui/src/stores/ui.svelte.ts') diff --git a/ui/src/stores/ui.svelte.ts b/ui/src/stores/ui.svelte.ts new file mode 100644 index 0000000..8fc339b --- /dev/null +++ b/ui/src/stores/ui.svelte.ts @@ -0,0 +1,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(); -- cgit v1.2.3-70-g09d2 From 66f401fd1248ce8d1624ec82342af5e07c51554e Mon Sep 17 00:00:00 2001 From: Natsuu Date: Wed, 14 Jan 2026 03:52:30 +0000 Subject: refactor: enhance UIState class by adding type for currentView and updating setView method --- ui/src/stores/ui.svelte.ts | 26 ++++++++++++-------------- ui/src/types/index.ts | 2 ++ 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'ui/src/stores/ui.svelte.ts') diff --git a/ui/src/stores/ui.svelte.ts b/ui/src/stores/ui.svelte.ts index 8fc339b..b010390 100644 --- a/ui/src/stores/ui.svelte.ts +++ b/ui/src/stores/ui.svelte.ts @@ -1,32 +1,30 @@ +import { type ViewType } from "../types"; + export class UIState { - currentView = $state("home"); + currentView: ViewType = $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) { + if (this.statusTimeout) clearTimeout(this.statusTimeout); + this.status = msg; + + if (msg !== "Ready") { + this.statusTimeout = setTimeout(() => { + this.status = "Ready"; + }, 5000); + } } toggleConsole() { this.showConsole = !this.showConsole; } - setView(view: string) { + setView(view: ViewType) { this.currentView = view; } } diff --git a/ui/src/types/index.ts b/ui/src/types/index.ts index dc0915b..b7ff0a0 100644 --- a/ui/src/types/index.ts +++ b/ui/src/types/index.ts @@ -1,3 +1,5 @@ +export type ViewType = "home" | "versions" | "settings"; + export interface Version { id: string; type: string; -- cgit v1.2.3-70-g09d2 From e636559dbc509a305dc372887fd1549322092d72 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Wed, 14 Jan 2026 12:03:04 +0800 Subject: chore: add ReturnType type hint Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- ui/src/stores/ui.svelte.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/src/stores/ui.svelte.ts') diff --git a/ui/src/stores/ui.svelte.ts b/ui/src/stores/ui.svelte.ts index b010390..9c29c25 100644 --- a/ui/src/stores/ui.svelte.ts +++ b/ui/src/stores/ui.svelte.ts @@ -5,8 +5,8 @@ export class UIState { status = $state("Ready"); showConsole = $state(false); appVersion = $state("..."); - - private statusTimeout: any; + + private statusTimeout: ReturnType | null = null; setStatus(msg: string) { if (this.statusTimeout) clearTimeout(this.statusTimeout); -- cgit v1.2.3-70-g09d2