fix(layout): cache pageWidth in localStorage to avoid render glitch

The page width from .remanso.json was only applied after an async
PouchDB + network fetch, so notes briefly rendered at the default
500px before snapping to the configured value. Persist pageWidth
alongside the existing font cache (key renamed to remanso:layout:*),
so it is read synchronously during setUserRepo and applied before
the first render. Also always reset --note-width with a default
fallback to prevent stale values leaking across repo navigation.
This commit is contained in:
Julien Calixte
2026-04-26 13:44:10 +02:00
parent 181ffd1e5c
commit 9f75e7971d
2 changed files with 23 additions and 20 deletions

View File

@@ -6,6 +6,7 @@ import { downloadFont } from "@/utils/downloadFont"
const DEFAULT_FONT_POLICY = '"Libertinus Serif", serif'
const DEFAULT_FONT_SIZE = "16px"
const DEFAULT_NOTE_WIDTH = "500px"
export const useUserSettings = () => {
const store = useUserRepoStore()
@@ -24,10 +25,8 @@ export const useUserSettings = () => {
)
root.style.setProperty("--font-size", fontSize || DEFAULT_FONT_SIZE)
const pageWidth = store.userSettings?.pageWidth
if (pageWidth) {
root.style.setProperty("--note-width", pageWidth)
resetNoteWidthCache()
}
const pageWidth = store.userSettings?.pageWidth ?? DEFAULT_NOTE_WIDTH
root.style.setProperty("--note-width", pageWidth)
resetNoteWidthCache()
})
}