From 9c1c924f209b41212bc629ca0d23f55d6a38b51d Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Thu, 11 Sep 2025 20:38:04 -0500 Subject: [PATCH] Update breadcrumb when updating photos --- src/admin/AdminPhotosUpdateClient.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/admin/AdminPhotosUpdateClient.tsx b/src/admin/AdminPhotosUpdateClient.tsx index 273bae4a..bde5c7e7 100644 --- a/src/admin/AdminPhotosUpdateClient.tsx +++ b/src/admin/AdminPhotosUpdateClient.tsx @@ -32,6 +32,7 @@ export default function AdminPhotosUpdateClient({ const errorRef = useRef(undefined); // Use state for updating progress button and error UI + const [updateCount, setUpdateCount] = useState(photos.length); const [statusText, setStatusText] = useState(getPhotosUpdateStatusText(photos)); const [photoIdsSyncing, setPhotoIdsSyncing] = useState([]); @@ -53,22 +54,22 @@ export default function AdminPhotosUpdateClient({ backLabel="Photos" backPath={PATH_ADMIN_PHOTOS} breadcrumb={ - Updates ({photos.length}) + Updates ({updateCount}) } accessory={} hideText="never" progress={progress} - tooltip={photos.length === 1 + tooltip={updateCount === 1 ? 'Update 1 photo' - : `Update all ${photos.length} photos`} + : `Update all ${updateCount} photos`} onClick={async () => { if (window.confirm([ 'Are you sure you want to sync', - photos.length === 1 + updateCount === 1 ? '1 photo?' - : `all ${photos.length} photos?`, + : `all ${updateCount} photos?`, 'Browser must remain open while syncing.', 'This action cannot be undone.', ].join(' '))) { @@ -88,8 +89,10 @@ export default function AdminPhotosUpdateClient({ photoIdsToSync.current = photoIdsToSync.current.filter( id => !photoIds.includes(id), ); - setStatusText(getPhotosUpdateStatusText(photos - .filter(({ id }) => photoIdsToSync.current.includes(id)))); + const photosRemaining = photos + .filter(({ id }) => photoIdsToSync.current.includes(id)); + setStatusText(getPhotosUpdateStatusText(photosRemaining)); + setUpdateCount(photosRemaining.length); setProgress( (photos.length - photoIdsToSync.current.length) / photos.length,