From 73a60147507f57f16bd494ffd9122e9c4a02c897 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Mon, 6 Apr 2026 18:51:27 +0200 Subject: [PATCH] fix: persist font selections across navigation and page reloads - Use v-model with writable computeds instead of :value+@change so selects re-sync when the options list changes asynchronously - Always include currently chosen fonts in sortedFontFamilies so a selected font not present in .remanso.json fontFamilies still shows in the select - Initialize userSettings instead of returning early in font setters so changes made before async GitHub fetch completes are not silently dropped - Back font choices with localStorage so they survive hard reloads even when PouchDB/IndexedDB fails silently in the web worker --- src/components/FontChange.vue | 33 +++++++++++++------ src/modules/repo/store/userRepo.store.ts | 41 +++++++++++++++++++++--- 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/src/components/FontChange.vue b/src/components/FontChange.vue index 8d8fabe..36e09d3 100644 --- a/src/components/FontChange.vue +++ b/src/components/FontChange.vue @@ -22,10 +22,28 @@ const DEFAULT_FONT_FAMILIES = [ const fontFamilies = computed( () => store.userSettings?.fontFamilies ?? DEFAULT_FONT_FAMILIES ) -const sortedFontFamilies = computed(() => - [...fontFamilies.value].sort((a, b) => a.localeCompare(b)) -) +const sortedFontFamilies = computed(() => { + const base = fontFamilies.value + const extras = [ + store.userSettings?.chosenTitleFont, + store.userSettings?.chosenBodyFont + ].filter((f): f is string => !!f && !base.includes(f)) + return [...base, ...extras].sort((a, b) => a.localeCompare(b)) +}) const fontSizes = Array.from({ length: 7 }, (_, i) => `${9 + i * 2}pt`) + +const titleFont = computed({ + get: () => store.userSettings?.chosenTitleFont, + set: (value) => store.setTitleFont(value!) +}) +const bodyFont = computed({ + get: () => store.userSettings?.chosenBodyFont, + set: (value) => store.setBodyFont(value!) +}) +const fontSize = computed({ + get: () => store.userSettings?.chosenFontSize, + set: (value) => store.setFontSize(value!) +})