refactor: centralize chart max/avg value state to global store

This commit is contained in:
henrygd
2025-02-22 15:28:07 -05:00
parent ba7db28e80
commit 6404895a47
2 changed files with 22 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
import PocketBase from "pocketbase"
import { atom, map, WritableAtom } from "nanostores"
import { atom, map, PreinitializedWritableAtom } from "nanostores"
import { AlertRecord, ChartTimes, SystemRecord, UserSettings } from "@/types"
import { basePath } from "@/components/router"
@@ -22,7 +22,10 @@ export const $publicKey = atom("")
export const $hubVersion = atom("")
/** Chart time period */
export const $chartTime = atom("1h") as WritableAtom<ChartTimes>
export const $chartTime = atom("1h") as PreinitializedWritableAtom<ChartTimes>
/** Whether to display average or max chart values */
export const $maxValues = atom(false)
/** User settings */
export const $userSettings = map<UserSettings>({