Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

take 1

Manav Rathi488402156ff0
diff --git a/web/apps/photos/src/components/PhotoList/index.tsx b/web/apps/photos/src/components/PhotoList/index.tsx
index 72b15ac75a..b83fe3bd4b 100644
--- a/web/apps/photos/src/components/PhotoList/index.tsx
+++ b/web/apps/photos/src/components/PhotoList/index.tsx
@@ -828,9 +828,7 @@ export function PhotoList({
console.timeEnd("c2");
console.time("c3");
- filesOnADay.forEach((file) => {
- handleSelect(file)(isDateSelected);
- });
+ handleSelect(filesOnADay)(isDateSelected);
console.timeEnd("c3");
};
diff --git a/web/apps/photos/src/utils/photoFrame/index.ts b/web/apps/photos/src/utils/photoFrame/index.ts
index 06d8d41207..d549be0262 100644
--- a/web/apps/photos/src/utils/photoFrame/index.ts
+++ b/web/apps/photos/src/utils/photoFrame/index.ts
@@ -143,7 +143,7 @@ export const handleSelectCreatorMulti =
activeCollectionID: number,
activePersonID: string | undefined,
) =>
- ({ id, ownerID }: { id: number; ownerID: number }) =>
+ (files: { id: number; ownerID: number }[]) =>
(checked: boolean) => {
setSelected((selected) => {
if (!mode) {
@@ -224,35 +224,30 @@ export const handleSelectCreatorMulti =
? { mode, personID: activePersonID! }
: { mode, collectionID: activeCollectionID! };
- const handleCounterChange = (count: number) => {
- if (selected[id] === checked) {
- return count;
+ const newSelected = { ...selected };
+ let newCount = selected.count;
+ let newOwnCount = selected.ownCount;
+
+ if (checked) {
+ for (const file of files) {
+ newSelected[file.id] = true;
+ newCount++;
+ if (file.ownerID === userID) newOwnCount++;
}
- if (checked) {
- return count + 1;
- } else {
- return count - 1;
+ } else {
+ for (const file of files) {
+ newSelected[file.id] = false;
+ newCount--;
+ if (file.ownerID === userID) newOwnCount--;
}
- };
+ }
- const handleAllCounterChange = () => {
- if (ownerID === userID) {
- return {
- ownCount: handleCounterChange(selected.ownCount),
- count: handleCounterChange(selected.count),
- };
- } else {
- return {
- count: handleCounterChange(selected.count),
- };
- }
- };
return {
- ...selected,
- [id]: checked,
+ ...newSelected,
+ count: newCount,
+ ownCount: newOwnCount,
collectionID: activeCollectionID,
context: newContext,
- ...handleAllCounterChange(),
};
});
};