From 38cf14b93d061b992aac6a4ce688abfd73473d73 Mon Sep 17 00:00:00 2001 From: Varun Raj Date: Wed, 29 Oct 2025 23:19:20 +0530 Subject: [PATCH] refactor: simplify asset mapping in MissingLocationAssets component - Removed the additional tags for assets in the MissingLocationAssets component, returning only the sorted assets. - Updated AssetGrid to include Immich link tags for each asset, utilizing the exImmichUrl from the configuration context. - Enhanced the dependency array for the asset mapping effect to include exImmichUrl for proper updates. --- .../missing-location/MissingLocationAssets.tsx | 14 +------------- src/components/shared/AssetGrid.tsx | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/components/assets/missing-location/MissingLocationAssets.tsx b/src/components/assets/missing-location/MissingLocationAssets.tsx index a60b2b4..b06c436 100644 --- a/src/components/assets/missing-location/MissingLocationAssets.tsx +++ b/src/components/assets/missing-location/MissingLocationAssets.tsx @@ -51,19 +51,7 @@ export default function MissingLocationAssets({ groupBy }: IProps) { sortedAssets = [...assets]; } - return sortedAssets.map((asset) => ({ - ...asset, - tags: [ - { - title: "Immich Link", - value: ( - - Open in Immich - - ), - }, - ], - })); + return sortedAssets; }, [assets, sortOrder, exImmichUrl]); const handleSelectionChange = (ids: string[]) => { diff --git a/src/components/shared/AssetGrid.tsx b/src/components/shared/AssetGrid.tsx index fbcd366..473e5be 100644 --- a/src/components/shared/AssetGrid.tsx +++ b/src/components/shared/AssetGrid.tsx @@ -8,6 +8,7 @@ import LazyGridImage from "../ui/lazy-grid-image"; import Download from "yet-another-react-lightbox/plugins/download"; import Video from "yet-another-react-lightbox/plugins/video"; import { usePhotoSelectionContext } from '@/contexts/PhotoSelectionContext'; +import { useConfig } from '@/contexts/ConfigContext'; interface AssetGridProps { @@ -26,7 +27,7 @@ interface AssetGridRef { const AssetGrid = forwardRef(({ assets, isInternal = true, selectable = false, onSelectionChange }, ref) => { const [index, setIndex] = useState(-1); const [lastSelectedIndex, setLastSelectedIndex] = useState(-1); - + const { exImmichUrl } = useConfig(); // Use context for selection state const { selectedIds, updateContext } = usePhotoSelectionContext(); @@ -112,8 +113,18 @@ const AssetGrid = forwardRef(({ assets, isInternal orientation: 1, isSelected: selectedIds.includes(p.id), isVideo: p.type === "VIDEO", + tags: [ + { + title: "Immich Link", + value: ( + + Open in Immich + + ), + }, + ], })); - }, [assets, selectedIds]); + }, [assets, selectedIds, exImmichUrl]); const handleEsc = (event: KeyboardEvent) => { if (event.key === "Escape") {