From 2fea44bde626602aaaf1c896f36d5c1df9bd8576 Mon Sep 17 00:00:00 2001 From: Yuri Karamian Date: Thu, 11 Jun 2026 20:48:20 +0200 Subject: [PATCH] Vault picker: remove a vault from the Recent list (#93); fix Tasks view showing "All Notes" as the mobile header title --- src-tauri/src/commands.rs | 11 +++++ src-tauri/src/lib.rs | 1 + src/lib/api.ts | 4 ++ src/lib/components/AppLayout.svelte | 2 +- src/lib/components/VaultPicker.svelte | 69 +++++++++++++++++++++++++-- 5 files changed, 81 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 3bc208a..06821d9 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -51,6 +51,17 @@ pub fn open_vault(app: AppHandle, state: State<'_, AppState>, path: String) -> R Ok(()) } +#[tauri::command] +pub fn remove_vault(state: State<'_, AppState>, path: String) -> Result<(), String> { + let mut config = state.config.lock().map_err(|e| e.to_string())?; + config.vaults.retain(|v| v.path != path); + if config.active_vault.as_deref() == Some(path.as_str()) { + config.active_vault = None; + } + save_app_config(&config)?; + Ok(()) +} + #[tauri::command] pub fn get_app_config(state: State<'_, AppState>) -> Result { let config = state.config.lock().map_err(|e| e.to_string())?; diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 7ae937b..7730bfb 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -98,6 +98,7 @@ pub fn run() { .manage(app_state) .invoke_handler(tauri::generate_handler![ commands::open_vault, + commands::remove_vault, commands::get_app_config, commands::set_theme, commands::set_accent_color, diff --git a/src/lib/api.ts b/src/lib/api.ts index f677e25..d6fed5e 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -20,6 +20,10 @@ export async function openVault(path: string): Promise { return invoke("open_vault", { path }); } +export async function removeVault(path: string): Promise { + return invoke("remove_vault", { path }); +} + export async function getAppConfig(): Promise { return invoke("get_app_config"); } diff --git a/src/lib/components/AppLayout.svelte b/src/lib/components/AppLayout.svelte index 0008790..7a1b2ba 100644 --- a/src/lib/components/AppLayout.svelte +++ b/src/lib/components/AppLayout.svelte @@ -724,7 +724,7 @@ {#if $mobileView === 'sidebar'} HelixNotes {:else} - {#if $viewMode === 'notebook'}{$activeNotebook?.name ?? 'Notebook'}{:else if $viewMode === 'tag'}#{$activeTag}{:else if $viewMode === 'quickaccess'}Quick Access{:else if $viewMode === 'daily'}Daily Notes{:else if $viewMode === 'trash'}Trash{:else}All Notes{/if} + {#if $viewMode === 'notebook'}{$activeNotebook?.name ?? 'Notebook'}{:else if $viewMode === 'tag'}#{$activeTag}{:else if $viewMode === 'quickaccess'}Quick Access{:else if $viewMode === 'daily'}Daily Notes{:else if $viewMode === 'tasks'}Tasks{:else if $viewMode === 'trash'}Trash{:else}All Notes{/if} {/if} {#if $globalUpdateAvailable && $mobileView === 'sidebar'} diff --git a/src/lib/components/VaultPicker.svelte b/src/lib/components/VaultPicker.svelte index f65bca3..460423c 100644 --- a/src/lib/components/VaultPicker.svelte +++ b/src/lib/components/VaultPicker.svelte @@ -2,7 +2,7 @@ import { open } from '@tauri-apps/plugin-dialog'; import { getCurrentWindow } from '@tauri-apps/api/window'; import { documentDir } from '@tauri-apps/api/path'; - import { openVault, getAppConfig } from '$lib/api'; + import { openVault, removeVault, getAppConfig } from '$lib/api'; import { appConfig, vaultReady } from '$lib/stores/app'; import { isAndroid, isIOS, isMobile } from '$lib/platform'; import type { VaultConfig } from '$lib/types'; @@ -107,6 +107,15 @@ loading = false; } } + + async function forgetVault(path: string) { + try { + await removeVault(path); + $appConfig = await getAppConfig(); + } catch (e) { + error = String(e); + } + } @@ -205,10 +214,18 @@
Recent {#each recentVaults as vault} - +
+ + +
{/each}
{/if} @@ -389,6 +406,48 @@ white-space: nowrap; } + .vault-row { + display: flex; + align-items: stretch; + gap: 6px; + margin-bottom: 6px; + } + + .vault-row .vault-item { + flex: 1; + min-width: 0; + margin-bottom: 0; + } + + .vault-remove { + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + width: 36px; + background: var(--bg-secondary); + border: 1px solid var(--border-color); + border-radius: 8px; + color: var(--text-tertiary); + cursor: pointer; + opacity: 0; + transition: opacity 0.15s, background 0.15s, color 0.15s; + } + + .vault-row:hover .vault-remove, + .vault-remove:focus-visible { + opacity: 1; + } + + .vault-remove:hover { + background: var(--bg-hover); + color: var(--text-primary); + } + + .vault-picker.mobile .vault-remove { + opacity: 1; + } + .vault-name-input { margin-bottom: 20px; text-align: left;