High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(web): person asset count doesn't update when navigating (#24438)
Yaroscca037b03c67
diff --git a/web/src/lib/components/timeline/actions/TimelineKeyboardActions.svelte b/web/src/lib/components/timeline/actions/TimelineKeyboardActions.svelteindex 00ac128663..5514965be2 100644--- a/web/src/lib/components/timeline/actions/TimelineKeyboardActions.svelte+++ b/web/src/lib/components/timeline/actions/TimelineKeyboardActions.svelte@@ -6,6 +6,7 @@setFocusTo as setFocusToInit,} from '$lib/components/timeline/actions/focus-actions';import { AppRoute } from '$lib/constants';+ import { eventManager } from '$lib/managers/event-manager.svelte';import { featureFlagsManager } from '$lib/managers/feature-flags-manager.svelte';import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';import type { TimelineAsset } from '$lib/managers/timeline-manager/types';@@ -46,7 +47,10 @@await deleteAssets(force,- (assetIds) => timelineManager.removeAssets(assetIds),+ (assetIds) => {+ timelineManager.removeAssets(assetIds);+ eventManager.emit('AssetsDelete', assetIds);+ },selectedAssets,force ? undefined : (assets) => timelineManager.upsertAssets(assets),);@@ -70,6 +74,7 @@const visibility = assetInteraction.isAllArchived ? AssetVisibility.Timeline : AssetVisibility.Archive;const ids = await archiveAssets(assetInteraction.selectedAssets, visibility);timelineManager.update(ids, (asset) => (asset.visibility = visibility));+ eventManager.emit('AssetsArchive', ids);deselectAllAssets();};diff --git a/web/src/lib/managers/event-manager.svelte.ts b/web/src/lib/managers/event-manager.svelte.tsindex 8325977ddc..9fbe16b68a 100644--- a/web/src/lib/managers/event-manager.svelte.ts+++ b/web/src/lib/managers/event-manager.svelte.ts@@ -32,6 +32,8 @@ export type Events = {AssetUpdate: [AssetResponseDto];AssetReplace: [{ oldAssetId: string; newAssetId: string }];+ AssetsArchive: [string[]];+ AssetsDelete: [string[]];AlbumAddAssets: [];AlbumUpdate: [AlbumResponseDto];diff --git a/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelteindex b338e195c0..48f559ffe6 100644--- a/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte+++ b/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte@@ -40,13 +40,7 @@import { getPeopleThumbnailUrl } from '$lib/utils';import { handleError } from '$lib/utils/handle-error';import { isExternalUrl } from '$lib/utils/navigation';- import {- AssetVisibility,- getPersonStatistics,- searchPerson,- updatePerson,- type PersonResponseDto,- } from '@immich/sdk';+ import { AssetVisibility, searchPerson, updatePerson, type PersonResponseDto } from '@immich/sdk';import { LoadingSpinner, modalManager, toastManager } from '@immich/ui';import {mdiAccountBoxOutline,@@ -70,7 +64,7 @@let { data }: Props = $props();- let numberOfAssets = $state(data.statistics.assets);+ let numberOfAssets = $derived(data.statistics.assets);let { isViewing: showAssetViewer } = assetViewingStore;let timelineManager = $state<TimelineManager>() as TimelineManager;@@ -129,12 +123,7 @@};const updateAssetCount = async () => {- try {- const { assets } = await getPersonStatistics({ id: person.id });- numberOfAssets = assets;- } catch (error) {- handleError(error, "Can't update the asset count");- }+ await invalidateAll();};afterNavigate(({ from }) => {@@ -344,7 +333,7 @@const { SetDateOfBirth } = $derived(getPersonActions($t, person));</script>-<OnEvents {onPersonUpdate} />+<OnEvents {onPersonUpdate} onAssetsDelete={updateAssetCount} onAssetsArchive={updateAssetCount} /><mainclass="relative z-0 h-dvh overflow-hidden px-2 md:px-6 md:pt-(--navbar-height-md) pt-(--navbar-height)"