fix(ui): keep trash counter in sync with trash changes

Reload the rail trash count after every operation that changes the
trash contents, not just navigation and empty-trash: moving photos to
trash (grid, panel, viewer), restoring, permanent delete and deleting
an album. Previously the counter stayed stale until the next route
change.
This commit is contained in:
iu
2026-10-12 12:58:18 +03:00
parent bf3641f9e0
commit 713c1ca6d3
11 changed files with 165 additions and 0 deletions
@@ -6,6 +6,7 @@
import { portal } from '$lib/actions/portal';
import { albums } from '$lib/stores/albums.svelte';
import { albumActions } from '$lib/stores/album-actions.svelte';
import { trash } from '$lib/stores/trash.svelte';
let title = $state('');
let busy = $state(false);
@@ -48,6 +49,7 @@
try {
await albums.destroy(a.id);
albumActions.deleting = null;
await trash.load();
if ($page.params.id === a.id) await goto('/');
} catch (e) {
error = (e as Error).message;
@@ -8,6 +8,7 @@
import { auth } from '$lib/stores/auth.svelte';
import { albums } from '$lib/stores/albums.svelte';
import { transfer } from '$lib/stores/transfer.svelte';
import { trash } from '$lib/stores/trash.svelte';
import { viewerActions } from '$lib/stores/viewer-actions.svelte';
import { buildExifRows, EXIF_BASE, EXIF_CATALOG, EXIF_LABELS } from '$lib/exif';
import type { Photo, Preferences, Tag } from '$lib/types';
@@ -193,6 +194,7 @@
try {
await photosApi.deleteBatch([photo.id]);
pendingDelete = false;
await trash.load();
onDeleted?.();
} catch {
/* ignore */