Skip to content

Commit f282ad6

Browse files
committed
fixup! feat(web): port similar images implementation from origin/main
fix: recompute filtered groups before calculating deletable stats When an individual item is toggled, the updated selection is stored in updatedAllGroups, but the deletable counts were computed from filteredGroups, which was derived before the update. This caused the remove count/size to stay stale after toggling items until another action recalculated state.
1 parent 03ef360 commit f282ad6

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

web/packages/new/photos/pages/similar-images.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,13 @@ const similarImagesReducer: React.Reducer<
386386
deletableItems.length > 0 &&
387387
deletableItems.every((i) => i.isSelected);
388388

389+
// Recompute filtered groups from updatedAllGroups to get accurate stats
390+
const updatedFilteredGroups = filterGroupsByCategory(
391+
updatedAllGroups,
392+
state.categoryFilter,
393+
);
389394
const { deletableCount, deletableSize } =
390-
calculateDeletableStats(filteredGroups);
395+
calculateDeletableStats(updatedFilteredGroups);
391396
return {
392397
...state,
393398
allSimilarImageGroups: updatedAllGroups,
@@ -711,6 +716,10 @@ const SimilarImages: React.FC<SimilarImagesProps> = ({
711716
progress={removeProgress}
712717
onRemove={onRemoveSimilarImages}
713718
/>
719+
</Stack>
720+
</Stack>
721+
);
722+
};
714723

715724
interface CategoryTabsProps {
716725
categoryFilter: CategoryFilter;
@@ -963,12 +972,12 @@ const ItemGrid = styled("div", {
963972
shouldForwardProp: (prop) => prop != "layoutParams",
964973
})<SimilarImagesItemGridProps>(
965974
({ layoutParams }) => `
966-
display: grid;
967-
padding-inline: ${layoutParams.paddingInline}px;
968-
grid-template-columns: repeat(${layoutParams.columns}, ${layoutParams.itemWidth}px);
969-
grid-auto-rows: ${layoutParams.itemHeight}px;
970-
gap: ${layoutParams.gap}px;
971-
`,
975+
display: grid;
976+
padding-inline: ${layoutParams.paddingInline}px;
977+
grid-template-columns: repeat(${layoutParams.columns}, ${layoutParams.itemWidth}px);
978+
grid-auto-rows: ${layoutParams.itemHeight}px;
979+
gap: ${layoutParams.gap}px;
980+
`,
972981
);
973982

974983
const GroupContent: React.FC<GroupContentProps> = ({

0 commit comments

Comments
 (0)