From 17e4cfd96b81cc876cb18a2c6cd0a46db4b4bd93 Mon Sep 17 00:00:00 2001 From: "immich-push-o-matic[bot]" <179150890+immich-push-o-matic[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2026 14:59:47 +0000 Subject: [PATCH] fix(web): no trash actions when trash is empty (#32104) fix(web): no trash actions when trash is empty (#32097) (cherry picked from commit c826e0d45aaa62187189921e9ac40297b13a37c4) Co-authored-by: Mees Frensel <33722705+meesfrensel@users.noreply.github.com> --- web/src/lib/services/trash.service.ts | 8 +++++--- .../trash/[[photos=photos]]/[[assetId=id]]/+page.svelte | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/web/src/lib/services/trash.service.ts b/web/src/lib/services/trash.service.ts index 10731b9f0..3fbe7a91c 100644 --- a/web/src/lib/services/trash.service.ts +++ b/web/src/lib/services/trash.service.ts @@ -5,23 +5,25 @@ import type { MessageFormatter } from 'svelte-i18n'; import { handleError } from '$lib/utils/handle-error'; import { getFormatter } from '$lib/utils/i18n'; -export const getTrashActions = ($t: MessageFormatter) => { +export const getTrashActions = ($t: MessageFormatter, assetCount: number) => { const RestoreAll: ActionItem = { title: $t('restore_all'), icon: mdiHistory, + $if: () => assetCount > 0, onAction: () => handleRestoreTrash(), }; const Empty: ActionItem = { title: $t('empty_trash'), icon: mdiDeleteForeverOutline, + $if: () => assetCount > 0, onAction: () => handleEmptyTrash(), }; return { RestoreAll, Empty }; }; -export const handleEmptyTrash = async () => { +const handleEmptyTrash = async () => { const $t = await getFormatter(); const confirmed = await modalManager.showDialog({ prompt: $t('empty_trash_confirmation') }); @@ -37,7 +39,7 @@ export const handleEmptyTrash = async () => { } }; -export const handleRestoreTrash = async () => { +const handleRestoreTrash = async () => { const $t = await getFormatter(); const confirmed = await modalManager.showDialog({ prompt: $t('assets_restore_confirmation') }); diff --git a/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.svelte index 228cd58c3..46e8b46be 100644 --- a/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.svelte +++ b/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.svelte @@ -40,7 +40,7 @@ return; }; - const { Empty, RestoreAll } = $derived(getTrashActions($t)); + const { Empty, RestoreAll } = $derived(getTrashActions($t, timelineManager?.assetCount ?? 0)); {#if featureFlagsManager.value.trash}