This commit is contained in:
Manav Rathi 2025-02-21 15:45:46 +05:30
parent e80e602786
commit 488402156f
No known key found for this signature in database
2 changed files with 21 additions and 28 deletions

View File

@ -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");
};

View File

@ -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;
}
if (checked) {
return count + 1;
} else {
return count - 1;
}
};
const newSelected = { ...selected };
let newCount = selected.count;
let newOwnCount = selected.ownCount;
const handleAllCounterChange = () => {
if (ownerID === userID) {
return {
ownCount: handleCounterChange(selected.ownCount),
count: handleCounterChange(selected.count),
};
} else {
return {
count: handleCounterChange(selected.count),
};
if (checked) {
for (const file of files) {
newSelected[file.id] = true;
newCount++;
if (file.ownerID === userID) newOwnCount++;
}
};
} else {
for (const file of files) {
newSelected[file.id] = false;
newCount--;
if (file.ownerID === userID) newOwnCount--;
}
}
return {
...selected,
[id]: checked,
...newSelected,
count: newCount,
ownCount: newOwnCount,
collectionID: activeCollectionID,
context: newContext,
...handleAllCounterChange(),
};
});
};