mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor(web): on person thumbnail (#25422)
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import OnEvents from '$lib/components/OnEvents.svelte';
|
||||||
import { timeBeforeShowLoadingSpinner } from '$lib/constants';
|
import { timeBeforeShowLoadingSpinner } from '$lib/constants';
|
||||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||||
import { photoViewerImgElement } from '$lib/stores/assets-store.svelte';
|
import { photoViewerImgElement } from '$lib/stores/assets-store.svelte';
|
||||||
import { boundingBoxesArray } from '$lib/stores/people.store';
|
import { boundingBoxesArray } from '$lib/stores/people.store';
|
||||||
import { websocketEvents } from '$lib/stores/websocket';
|
|
||||||
import { getPeopleThumbnailUrl, handlePromiseError } from '$lib/utils';
|
import { getPeopleThumbnailUrl, handlePromiseError } from '$lib/utils';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
import { zoomImageToBase64 } from '$lib/utils/people-utils';
|
import { zoomImageToBase64 } from '$lib/utils/people-utils';
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
isShowLoadingPeople = false;
|
isShowLoadingPeople = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const onPersonThumbnail = (personId: string) => {
|
const onPersonThumbnailReady = ({ id }: { id: string }) => {
|
||||||
assetFaceGenerated.push(personId);
|
assetFaceGenerated.push(id);
|
||||||
if (
|
if (
|
||||||
isEqual(assetFaceGenerated, peopleToCreate) &&
|
isEqual(assetFaceGenerated, peopleToCreate) &&
|
||||||
loaderLoadingDoneTimeout &&
|
loaderLoadingDoneTimeout &&
|
||||||
@@ -86,7 +86,6 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
handlePromiseError(loadPeople());
|
handlePromiseError(loadPeople());
|
||||||
return websocketEvents.on('on_person_thumbnail', onPersonThumbnail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const isEqual = (a: string[], b: string[]): boolean => {
|
const isEqual = (a: string[], b: string[]): boolean => {
|
||||||
@@ -184,6 +183,8 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<OnEvents {onPersonThumbnailReady} />
|
||||||
|
|
||||||
<section
|
<section
|
||||||
transition:fly={{ x: 360, duration: 100, easing: linear }}
|
transition:fly={{ x: 360, duration: 100, easing: linear }}
|
||||||
class="absolute top-0 h-full w-90 overflow-x-hidden p-2 dark:text-immich-dark-fg bg-light"
|
class="absolute top-0 h-full w-90 overflow-x-hidden p-2 dark:text-immich-dark-fg bg-light"
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export type Events = {
|
|||||||
AlbumUserDelete: [{ albumId: string; userId: string }];
|
AlbumUserDelete: [{ albumId: string; userId: string }];
|
||||||
|
|
||||||
PersonUpdate: [PersonResponseDto];
|
PersonUpdate: [PersonResponseDto];
|
||||||
|
PersonThumbnailReady: [{ id: string }];
|
||||||
|
|
||||||
BackupDeleteStatus: [{ filename: string; isDeleting: boolean }];
|
BackupDeleteStatus: [{ filename: string; isDeleting: boolean }];
|
||||||
BackupDeleted: [{ filename: string }];
|
BackupDeleted: [{ filename: string }];
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ websocket
|
|||||||
.on('on_new_release', (event) => eventManager.emit('ReleaseEvent', event))
|
.on('on_new_release', (event) => eventManager.emit('ReleaseEvent', event))
|
||||||
.on('on_session_delete', () => authManager.logout())
|
.on('on_session_delete', () => authManager.logout())
|
||||||
.on('on_user_delete', (id) => eventManager.emit('UserAdminDeleted', { id }))
|
.on('on_user_delete', (id) => eventManager.emit('UserAdminDeleted', { id }))
|
||||||
|
.on('on_person_thumbnail', (id) => eventManager.emit('PersonThumbnailReady', { id }))
|
||||||
.on('on_notification', () => notificationManager.refresh())
|
.on('on_notification', () => notificationManager.refresh())
|
||||||
.on('connect_error', (e) => console.log('Websocket Connect Error', e));
|
.on('connect_error', (e) => console.log('Websocket Connect Error', e));
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import ImageThumbnail from '$lib/components/assets/thumbnail/image-thumbnail.svelte';
|
import ImageThumbnail from '$lib/components/assets/thumbnail/image-thumbnail.svelte';
|
||||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||||
|
import OnEvents from '$lib/components/OnEvents.svelte';
|
||||||
import EmptyPlaceholder from '$lib/components/shared-components/empty-placeholder.svelte';
|
import EmptyPlaceholder from '$lib/components/shared-components/empty-placeholder.svelte';
|
||||||
import SingleGridRow from '$lib/components/shared-components/single-grid-row.svelte';
|
import SingleGridRow from '$lib/components/shared-components/single-grid-row.svelte';
|
||||||
import { Route } from '$lib/route';
|
import { Route } from '$lib/route';
|
||||||
import { websocketEvents } from '$lib/stores/websocket';
|
|
||||||
import { getAssetThumbnailUrl, getPeopleThumbnailUrl } from '$lib/utils';
|
import { getAssetThumbnailUrl, getPeopleThumbnailUrl } from '$lib/utils';
|
||||||
import { AssetMediaSize, type SearchExploreResponseDto } from '@immich/sdk';
|
import { AssetMediaSize, type SearchExploreResponseDto } from '@immich/sdk';
|
||||||
import { Icon } from '@immich/ui';
|
import { Icon } from '@immich/ui';
|
||||||
import { mdiHeart } from '@mdi/js';
|
import { mdiHeart } from '@mdi/js';
|
||||||
import { onMount } from 'svelte';
|
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
@@ -29,17 +28,17 @@
|
|||||||
|
|
||||||
let hasPeople = $derived(data.response.total > 0);
|
let hasPeople = $derived(data.response.total > 0);
|
||||||
|
|
||||||
onMount(() => {
|
const onPersonThumbnailReady = ({ id }: { id: string }) => {
|
||||||
return websocketEvents.on('on_person_thumbnail', (personId: string) => {
|
for (const person of people) {
|
||||||
people.map((person) => {
|
if (person.id === id) {
|
||||||
if (person.id === personId) {
|
person.updatedAt = new Date().toISOString();
|
||||||
person.updatedAt = Date.now().toString();
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<OnEvents {onPersonThumbnailReady} />
|
||||||
|
|
||||||
<UserPageLayout title={data.meta.title}>
|
<UserPageLayout title={data.meta.title}>
|
||||||
{#if hasPeople}
|
{#if hasPeople}
|
||||||
<div class="mb-6 mt-2">
|
<div class="mb-6 mt-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user