From d558ea819a007140fdbfe06061dd3ae9c1ef814c Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 11 Jun 2024 06:30:42 -0500 Subject: [PATCH] fix(web): cannot perform duplication actions as normal user (#10115) * fix(web): cannot perform duplication actions as normal user * use immich dialog --- .../[[assetId=id]]/+page.svelte | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/web/src/routes/(user)/utilities/[duplicates]/[[photos=photos]]/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/utilities/[duplicates]/[[photos=photos]]/[[assetId=id]]/+page.svelte index 45d50a8e00..ae94b74a2f 100644 --- a/web/src/routes/(user)/utilities/[duplicates]/[[photos=photos]]/[[assetId=id]]/+page.svelte +++ b/web/src/routes/(user)/utilities/[duplicates]/[[photos=photos]]/[[assetId=id]]/+page.svelte @@ -9,25 +9,30 @@ notificationController, } from '$lib/components/shared-components/notification/notification'; import { s } from '$lib/utils'; - import { deleteAssets, getConfig, updateAssets } from '@immich/sdk'; + import { deleteAssets, updateAssets } from '@immich/sdk'; import { t } from 'svelte-i18n'; + import { featureFlags } from '$lib/stores/server-config.store'; + import { dialogController } from '$lib/components/shared-components/dialog/dialog'; export let data: PageData; const handleResolve = async (duplicateId: string, duplicateAssetIds: string[], trashIds: string[]) => { try { - const { trash } = await getConfig(); - // TODO - Create showConfirmDialog controller to show native confirm. - if ( - !trash.enabled && - trashIds.length > 0 && - !confirm('Are you sure you want to permanently delete these duplicates?') - ) { - return; + if (!$featureFlags.trash && trashIds.length > 0) { + const isConfirmed = await dialogController.show({ + title: 'Confirm', + prompt: 'Are you sure you want to permanently delete these duplicates?', + confirmText: 'Yes', + cancelText: 'No', + }); + + if (!isConfirmed) { + return; + } } await updateAssets({ assetBulkUpdateDto: { ids: duplicateAssetIds, duplicateId: null } }); - await deleteAssets({ assetBulkDeleteDto: { ids: trashIds, force: !trash.enabled } }); + await deleteAssets({ assetBulkDeleteDto: { ids: trashIds, force: !$featureFlags.trash } }); data.duplicates = data.duplicates.filter((duplicate) => duplicate.duplicateId !== duplicateId);