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:
@@ -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()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user