-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(web): View all duplicates page #15856
base: main
Are you sure you want to change the base?
Changes from 8 commits
afeb4e0
6d1a616
c7f9b50
9aa518d
82e9366
765e684
b3c7780
92c9f9d
4314f25
05f69b7
41d9216
67ff76c
132e559
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script lang="ts"> | ||
import Icon from '$lib/components/elements/icon.svelte'; | ||
import { AppRoute } from '$lib/constants'; | ||
import { getAssetThumbnailUrl } from '$lib/utils'; | ||
import { getAltText } from '$lib/utils/thumbnail-util'; | ||
import type { DuplicateResponseDto } from '@immich/sdk'; | ||
import { mdiImageMultipleOutline } from '@mdi/js'; | ||
|
||
interface Props { | ||
duplicate: DuplicateResponseDto; | ||
} | ||
|
||
let { duplicate }: Props = $props(); | ||
|
||
let assetToDisplay = duplicate.assets[0]; | ||
let title = $derived( | ||
JSON.stringify( | ||
duplicate.assets.map((asset) => asset.originalFileName), | ||
null, | ||
2, | ||
), | ||
); | ||
arnolicious marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</script> | ||
|
||
<a href="{AppRoute.DUPLICATES}/{duplicate.duplicateId}" class="block relative w-full"> | ||
<img | ||
src={getAssetThumbnailUrl(assetToDisplay.id)} | ||
alt={$getAltText(assetToDisplay)} | ||
{title} | ||
class="h-60 object-cover rounded-xl w-full" | ||
draggable="false" | ||
/> | ||
|
||
<div class="absolute top-2 right-3"> | ||
<div class="bg-immich-primary/90 px-2 py-1 my-0.5 rounded-xl text-xs text-white"> | ||
<div class="flex items-center justify-center"> | ||
<div class="mr-1">{duplicate.assets.length}</div> | ||
<Icon path={mdiImageMultipleOutline} size="18" /> | ||
</div> | ||
</div> | ||
</div> | ||
</a> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script lang="ts"> | ||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte'; | ||
import DuplicateThumbnail from '$lib/components/utilities-page/duplicates/duplicate-thumbnail.svelte'; | ||
import { locale } from '$lib/stores/preferences.store'; | ||
import type { PageData } from './$types'; | ||
|
||
interface Props { | ||
data: PageData; | ||
} | ||
|
||
let { data = $bindable() }: Props = $props(); | ||
|
||
let duplicates = $state(data.duplicates); | ||
</script> | ||
|
||
<UserPageLayout title={data.meta.title + ` (${duplicates.length.toLocaleString($locale)})`} scrollbar={true}> | ||
<section class="mt-2 h-[calc(100%-theme(spacing.20))] overflow-auto immich-scrollbar"> | ||
<div class="w-full grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-6 2xl:grid-cols-8 gap-2 rounded-2xl"> | ||
{#each duplicates as duplicate} | ||
<DuplicateThumbnail {duplicate} /> | ||
{/each} | ||
</div> | ||
</section> | ||
</UserPageLayout> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
import { mdiCheckOutline, mdiInformationOutline, mdiKeyboard, mdiTrashCanOutline } from '@mdi/js'; | ||
import { t } from 'svelte-i18n'; | ||
import type { PageData } from './$types'; | ||
import { AppRoute } from '$lib/constants'; | ||
import { goto } from '$app/navigation'; | ||
|
||
interface Props { | ||
data: PageData; | ||
|
@@ -54,6 +56,7 @@ | |
], | ||
}; | ||
|
||
let activeDuplicate = $state(data.activeDuplicate); | ||
let duplicates = $state(data.duplicates); | ||
let hasDuplicates = $derived(duplicates.length > 0); | ||
const withConfirmation = async (callback: () => Promise<void>, prompt?: string, confirmText?: string) => { | ||
|
@@ -90,9 +93,19 @@ | |
await deleteAssets({ assetBulkDeleteDto: { ids: trashIds, force: !$featureFlags.trash } }); | ||
await updateAssets({ assetBulkUpdateDto: { ids: duplicateAssetIds, duplicateId: null } }); | ||
|
||
const currentDuplicateIndex = duplicates.findIndex((duplicate) => duplicate.duplicateId === duplicateId); | ||
duplicates = duplicates.filter((duplicate) => duplicate.duplicateId !== duplicateId); | ||
|
||
deletedNotification(trashIds.length); | ||
|
||
// Move to the next duplicate | ||
if (duplicates.length > 0) { | ||
// The index of the next duplicate is the same as the current one, since we removed the current one | ||
activeDuplicate = duplicates[currentDuplicateIndex] || duplicates[0]; | ||
} else { | ||
// If there are no more duplicates, redirect to the duplicates page | ||
await goto(AppRoute.DUPLICATES); | ||
} | ||
}, | ||
trashIds.length > 0 && !$featureFlags.trash ? $t('delete_duplicates_confirmation') : undefined, | ||
trashIds.length > 0 && !$featureFlags.trash ? $t('permanently_delete') : undefined, | ||
|
@@ -103,7 +116,17 @@ | |
await stackAssets(assets, false); | ||
const duplicateAssetIds = assets.map((asset) => asset.id); | ||
await updateAssets({ assetBulkUpdateDto: { ids: duplicateAssetIds, duplicateId: null } }); | ||
const currentDuplicateIndex = duplicates.findIndex((duplicate) => duplicate.duplicateId === duplicateId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you just track the index instead of doing this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I don't think I really understand by "tracking" in this context. |
||
duplicates = duplicates.filter((duplicate) => duplicate.duplicateId !== duplicateId); | ||
|
||
// Move to the next duplicate | ||
if (duplicates.length > 0) { | ||
// The index of the next duplicate is the same as the current one, since we removed the current one | ||
activeDuplicate = duplicates[currentDuplicateIndex] || duplicates[0]; | ||
} else { | ||
// If there are no more duplicates, redirect to the duplicates page | ||
await goto(AppRoute.DUPLICATES); | ||
} | ||
}; | ||
|
||
const handleDeduplicateAll = async () => { | ||
|
@@ -209,12 +232,12 @@ | |
/> | ||
</div> | ||
|
||
{#key duplicates[0].duplicateId} | ||
{#key activeDuplicate.duplicateId} | ||
<DuplicatesCompareControl | ||
assets={duplicates[0].assets} | ||
assets={activeDuplicate.assets} | ||
onResolve={(duplicateAssetIds, trashIds) => | ||
handleResolve(duplicates[0].duplicateId, duplicateAssetIds, trashIds)} | ||
onStack={(assets) => handleStack(duplicates[0].duplicateId, assets)} | ||
handleResolve(activeDuplicate.duplicateId, duplicateAssetIds, trashIds)} | ||
onStack={(assets) => handleStack(activeDuplicate.duplicateId, assets)} | ||
/> | ||
{/key} | ||
{:else} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { authenticate } from '$lib/utils/auth'; | ||
import { getFormatter } from '$lib/utils/i18n'; | ||
import { getAssetDuplicates } from '@immich/sdk'; | ||
import { fail } from '@sveltejs/kit'; | ||
import type { PageLoad } from './$types'; | ||
|
||
export const load = (async ({ params }) => { | ||
await authenticate(); | ||
const duplicates = await getAssetDuplicates(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This view only needs to know the number of each duplicate group, not fetch all their members. It can fetch much less data with a different endpoint that only returns the data it actually needs (one asset to display per group, and the number of duplicates in the group). |
||
const $t = await getFormatter(); | ||
|
||
const activeDuplicate = duplicates.find((duplicate) => duplicate.duplicateId === params.duplicateId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here as well. |
||
|
||
if (!activeDuplicate) { | ||
return fail(404); | ||
} | ||
|
||
return { | ||
duplicates, | ||
activeDuplicate, | ||
meta: { | ||
title: $t('duplicates'), | ||
}, | ||
}; | ||
}) satisfies PageLoad; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this doesn't give a good indication that it's a button that takes you to a different view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this feature to see the duplicate info on the image details. I agree with mert about it not being clear that it is clickable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to improve this in the latest iteration :D