diff --git a/web/src/lib/components/faces-page/person-side-panel.svelte b/web/src/lib/components/faces-page/person-side-panel.svelte index 46f63fbed..2fb37f0cf 100644 --- a/web/src/lib/components/faces-page/person-side-panel.svelte +++ b/web/src/lib/components/faces-page/person-side-panel.svelte @@ -16,7 +16,6 @@ import { photoViewer } from '$lib/stores/assets.store'; import UnassignedFacesSidePannel from './unassigned-faces-side-pannel.svelte'; import type { FaceWithGeneretedThumbnail } from '$lib/utils/people-utils'; - import { cloneDeep } from 'lodash-es'; export let assetId: string; @@ -29,10 +28,9 @@ let selectedPersonToReassign: (PersonResponseDto | null)[]; let selectedPersonToCreate: (string | null)[]; let selectedPersonToAdd: FaceWithGeneretedThumbnail[] = []; - let selectedPersonToUnassign: AssetFaceResponseDto[] = []; + let selectedPersonToUnassign: FaceWithGeneretedThumbnail[] = []; let selectedPersonToRemove: boolean[] = []; let unassignedFaces: (FaceWithGeneretedThumbnail | null)[] = []; - let unassignedFacesOriginal: (FaceWithGeneretedThumbnail | null)[] = []; let editedPersonIndex: number; let shouldRefresh: boolean = false; @@ -94,7 +92,6 @@ } }), ); - unassignedFacesOriginal = cloneDeep(unassignedFaces); } catch (error) { handleError(error, "Can't get faces"); } finally { @@ -163,7 +160,8 @@ if (selectedPersonToRemove[i]) { const image = await zoomImageToBase64(peopleWithFaces[i], $photoViewer); if (image) { - selectedPersonToUnassign.push(peopleWithFaces[i]); + selectedPersonToUnassign.push({ ...peopleWithFaces[i], customThumbnail: image }); + // Trigger reactivity selectedPersonToUnassign = selectedPersonToUnassign; if (selectedPersonToReassign[i]) { selectedPersonToReassign[i] = null; @@ -183,8 +181,6 @@ const handleEditFaces = async () => { loaderLoadingDoneTimeout = setTimeout(() => (isShowLoadingDone = true), 100); - const uniqueIds = new Set(unassignedFacesOriginal.map((objA) => objA && objA.id)); - selectedPersonToUnassign = selectedPersonToUnassign.filter((objB) => !uniqueIds.has(objB.id)); const numberOfChanges = selectedPersonToCreate.filter((person) => person !== null).length + @@ -267,8 +263,6 @@ const handleCreateOrReassignFaceFromUnassignedFace = (face: FaceWithGeneretedThumbnail) => { selectedPersonToAdd.push(face); - const uniqueIds = new Set(selectedPersonToAdd.map((objA) => objA.id)); - selectedPersonToUnassign = selectedPersonToUnassign.filter((objB) => !uniqueIds.has(objB.id)); selectedPersonToAdd = selectedPersonToAdd; showUnassignedFaces = false; }; @@ -336,7 +330,7 @@
-
+
{#if peopleWithFaces.every((item) => item.person === null)}
@@ -357,7 +351,7 @@ {/if}
-
+
{#if isShowLoadingPeople}
@@ -440,95 +434,99 @@ {/if}
{#if selectedPersonToAdd.length > 0} - Faces to add -
- {#each selectedPersonToAdd as face, index} - {#if face} -
-
($boundingBoxesArray = [peopleWithFaces[index]])} - on:mouseover={() => ($boundingBoxesArray = [peopleWithFaces[index]])} - on:mouseleave={() => ($boundingBoxesArray = [])} - > -
- -
- {#if face.person?.name} -

- {face.person?.name} -

{/if} - {#if !isSelectingFaces} -
- +
+

Faces to add

+
+ {#each selectedPersonToAdd as face, index} + {#if face} +
+
($boundingBoxesArray = [peopleWithFaces[index]])} + on:mouseover={() => ($boundingBoxesArray = [peopleWithFaces[index]])} + on:mouseleave={() => ($boundingBoxesArray = [])} + > +
+
- {/if} + {#if face.person?.name} +

+ {face.person?.name} +

{/if} + {#if !isSelectingFaces} +
+ +
+ {/if} +
-
- {/if} - {/each} + {/if} + {/each} +
{/if} {#if selectedPersonToUnassign.length > 0} - Faces to unassign -
- {#each selectedPersonToUnassign as face, index} - {#if face && face.person} -
-
($boundingBoxesArray = [peopleWithFaces[index]])} - on:mouseover={() => ($boundingBoxesArray = [peopleWithFaces[index]])} - on:mouseleave={() => ($boundingBoxesArray = [])} - > -
- -
- {#if face.person?.name} -

- {face.person?.name} -

{/if} - {#if !isSelectingFaces} -
- +
+

Faces to unassign

+
+ {#each selectedPersonToUnassign as face, index} + {#if face && face.person} +
+
($boundingBoxesArray = [peopleWithFaces[index]])} + on:mouseover={() => ($boundingBoxesArray = [peopleWithFaces[index]])} + on:mouseleave={() => ($boundingBoxesArray = [])} + > +
+
- {/if} + {#if face.person?.name} +

+ {face.person?.name} +

{/if} + {#if !isSelectingFaces} +
+ +
+ {/if} +
-
- {/if} - {/each} + {/if} + {/each} +
{/if}
diff --git a/web/src/lib/components/faces-page/unassigned-faces-side-pannel.svelte b/web/src/lib/components/faces-page/unassigned-faces-side-pannel.svelte index ed79337ba..75ed3fde0 100644 --- a/web/src/lib/components/faces-page/unassigned-faces-side-pannel.svelte +++ b/web/src/lib/components/faces-page/unassigned-faces-side-pannel.svelte @@ -67,7 +67,7 @@
-

Faces Available

+

Faces available

{#if unassignedFaces.some((face) => face)}