@@ -7,6 +7,7 @@ import type {
77 FolioStatus ,
88 FolioStore
99} from './types' ;
10+ import { resolveSortMode } from './types' ;
1011import { extractDomain , normalizeUrl } from './url' ;
1112import { isSupportedLocale , writeStoredLocale } from '../shared/i18n/localeStore' ;
1213import { getThemeIconVariant , resolveFolioTheme } from '../shared/theme' ;
@@ -59,6 +60,7 @@ function normalizeStore(store: FolioStore): FolioStore {
5960 theme,
6061 defaultStatus :
6162 store . settings . defaultStatus === 'reading' ? 'reading' : 'unread' ,
63+ sortMode : resolveSortMode ( store . settings . sortMode ) ,
6264 syncDirectory :
6365 typeof store . settings . syncDirectory === 'string'
6466 ? store . settings . syncDirectory
@@ -173,6 +175,7 @@ function sanitizeImportedStore(raw: unknown, current: FolioStore): FolioStore |
173175 rawSettings . defaultStatus === 'unread' || rawSettings . defaultStatus === 'reading'
174176 ? rawSettings . defaultStatus
175177 : current . settings . defaultStatus ;
178+ const sortMode = resolveSortMode ( rawSettings . sortMode ?? current . settings . sortMode ) ;
176179 const theme = resolveFolioTheme ( rawSettings . theme ?? current . settings . theme ) ;
177180 const iconVariant = getThemeIconVariant ( theme ) ;
178181
@@ -186,6 +189,7 @@ function sanitizeImportedStore(raw: unknown, current: FolioStore): FolioStore |
186189 iconVariant,
187190 theme,
188191 defaultStatus,
192+ sortMode,
189193 syncDirectory :
190194 typeof current . settings . syncDirectory === 'string'
191195 ? current . settings . syncDirectory
@@ -241,6 +245,7 @@ export async function getStore(): Promise<FolioStore> {
241245 'iconVariant' ,
242246 'theme' ,
243247 'defaultStatus' ,
248+ 'sortMode' ,
244249 'syncDirectory' ,
245250 'lastSyncedAt' ,
246251 'lastSyncError'
@@ -439,6 +444,9 @@ export async function commit(mutation: FolioMutation): Promise<CommitResult> {
439444 if ( mutation . payload . defaultStatus !== undefined ) {
440445 next . settings . defaultStatus = mutation . payload . defaultStatus ;
441446 }
447+ if ( mutation . payload . sortMode !== undefined ) {
448+ next . settings . sortMode = mutation . payload . sortMode ;
449+ }
442450
443451 break ;
444452 }
0 commit comments