mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 09:19:56 -05:00
Fix: State-Based Issues & AboutSettings (WIP)
This commit is contained in:
@@ -32,6 +32,9 @@
|
||||
$effect(() => {
|
||||
getVersion().then(v => appVersion = v).catch(() => appVersion = "unknown");
|
||||
if (!releasesLoaded) { releasesLoaded = true; loadReleases(); }
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
loadServerInfo();
|
||||
});
|
||||
|
||||
@@ -92,9 +95,9 @@
|
||||
return new Date(iso).toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
|
||||
}
|
||||
|
||||
function fmtBuildTime(unix: number) {
|
||||
function fmtBuildTime(unix: number | string) {
|
||||
if (!unix) return "";
|
||||
return new Date(unix).toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
|
||||
return new Date(Number(unix) * 1000).toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
|
||||
}
|
||||
|
||||
function fmtBytes(bytes: number) {
|
||||
|
||||
+17
-10
@@ -10,6 +10,7 @@ import { notifications } from "./no
|
||||
import { app } from "./app.svelte";
|
||||
import { persistSettings, persistLibrary, persistUpdates } from "../core/persistence/persist";
|
||||
import type { PersistedData } from "../core/persistence/persist";
|
||||
import { untrack } from "svelte";
|
||||
|
||||
function localDateStr(d: Date): string {
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
||||
@@ -104,17 +105,23 @@ class Store {
|
||||
(saved.settings as any)[key] = (DEFAULT_SETTINGS as any)[key];
|
||||
}
|
||||
|
||||
this.settings = mergeSettings(saved);
|
||||
this.history = saved.history ?? [];
|
||||
this.bookmarks = saved.bookmarks ?? [];
|
||||
this.markers = saved.markers ?? [];
|
||||
this.readLog = saved.readLog ?? [];
|
||||
this.readingStats = saved.readingStats ?? { ...DEFAULT_READING_STATS };
|
||||
this.dailyReadCounts = saved.dailyReadCounts ?? {};
|
||||
this.libraryUpdates = saved.libraryUpdates ?? [];
|
||||
this.lastLibraryRefresh = saved.lastLibraryRefresh ?? 0;
|
||||
this.acknowledgedUpdates = new Set(saved.acknowledgedUpdateIds ?? []);
|
||||
// Assign all persisted values outside of reactive tracking so the
|
||||
// $effects registered below don't fire on this initial write.
|
||||
untrack(() => {
|
||||
this.settings = mergeSettings(saved);
|
||||
this.history = saved.history ?? [];
|
||||
this.bookmarks = saved.bookmarks ?? [];
|
||||
this.markers = saved.markers ?? [];
|
||||
this.readLog = saved.readLog ?? [];
|
||||
this.readingStats = saved.readingStats ?? { ...DEFAULT_READING_STATS };
|
||||
this.dailyReadCounts = saved.dailyReadCounts ?? {};
|
||||
this.libraryUpdates = saved.libraryUpdates ?? [];
|
||||
this.lastLibraryRefresh = saved.lastLibraryRefresh ?? 0;
|
||||
this.acknowledgedUpdates = new Set(saved.acknowledgedUpdateIds ?? []);
|
||||
});
|
||||
|
||||
// Mark ready before registering effects so the first reactive run
|
||||
// (which Svelte schedules after the current microtask) is allowed through.
|
||||
this.#ready = true;
|
||||
|
||||
$effect.root(() => {
|
||||
|
||||
Reference in New Issue
Block a user