Skip to content

High performance self-hosted photo and video management solution.

fix(web): no trash actions when trash is empty (#32097)

Mees Frenselc826e0d45aaa
diff --git a/web/src/lib/services/trash.service.ts b/web/src/lib/services/trash.service.ts
index 10731b9f00..3fbe7a91c7 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 228cd58c3a..46e8b46be0 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));
</script>
{#if featureFlagsManager.value.trash}