diff --git a/src-tauri/src/types.rs b/src-tauri/src/types.rs index a56e69e..16eb587 100644 --- a/src-tauri/src/types.rs +++ b/src-tauri/src/types.rs @@ -240,6 +240,8 @@ pub struct VaultState { pub notebook_sort_mode: String, #[serde(default)] pub notebook_order: std::collections::HashMap, + #[serde(default)] + pub sort_mode: String, } impl Default for VaultState { @@ -252,6 +254,7 @@ impl Default for VaultState { collapsed_notebooks: Vec::new(), notebook_sort_mode: String::new(), notebook_order: std::collections::HashMap::new(), + sort_mode: String::new(), } } } diff --git a/src/lib/components/AppLayout.svelte b/src/lib/components/AppLayout.svelte index 19b9714..4b9e61c 100644 --- a/src/lib/components/AppLayout.svelte +++ b/src/lib/components/AppLayout.svelte @@ -34,6 +34,7 @@ tags, notes, viewMode, + sortMode, activeTag, updateAvailable as globalUpdateAvailable, settingsTab, @@ -184,7 +185,8 @@ sidebar_collapsed: $sidebarCollapsed, collapsed_notebooks: $collapsedNotebooks, notebook_sort_mode: $notebookSortMode, - notebook_order: $notebookOrder + notebook_order: $notebookOrder, + sort_mode: $sortMode }; try { await saveVaultState(state); @@ -421,6 +423,11 @@ persistState(); }); + $effect(() => { + $sortMode; + persistState(); + }); + onMount(async () => { let lastNotePath: string | null = null; try { @@ -431,6 +438,7 @@ $collapsedNotebooks = state.collapsed_notebooks ?? []; $notebookSortMode = state.notebook_sort_mode === 'manual' ? 'manual' : 'alphabetical'; $notebookOrder = state.notebook_order ?? {}; + if (state.sort_mode === 'created' || state.sort_mode === 'title' || state.sort_mode === 'modified') $sortMode = state.sort_mode; lastNotePath = state.last_open_note ?? null; } catch (_) {} diff --git a/src/lib/types.ts b/src/lib/types.ts index 42412e3..cce9f39 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -100,6 +100,7 @@ export interface VaultState { collapsed_notebooks: string[]; notebook_sort_mode?: string; notebook_order?: Record; + sort_mode?: string; } export interface SearchResult {