fix handleSelection using old selection reference
This commit is contained in:
parent
e283eeab27
commit
f56b1fed5f
|
@ -450,9 +450,6 @@ const PhotoFrame = ({
|
|||
const handleSelect =
|
||||
(id: number, isOwnFile: boolean, index?: number) =>
|
||||
(checked: boolean) => {
|
||||
if (selected.collectionID !== activeCollection) {
|
||||
setSelected({ ownCount: 0, count: 0, collectionID: 0 });
|
||||
}
|
||||
if (typeof index !== 'undefined') {
|
||||
if (checked) {
|
||||
setRangeStart(index);
|
||||
|
@ -460,8 +457,12 @@ const PhotoFrame = ({
|
|||
setRangeStart(undefined);
|
||||
}
|
||||
}
|
||||
setSelected((selected) => {
|
||||
if (selected.collectionID !== activeCollection) {
|
||||
selected = { ownCount: 0, count: 0, collectionID: 0 };
|
||||
}
|
||||
|
||||
const handleCounter = (count: number) => {
|
||||
const handleCounterChange = (count: number) => {
|
||||
if (selected[id] === checked) {
|
||||
return count;
|
||||
}
|
||||
|
@ -472,25 +473,25 @@ const PhotoFrame = ({
|
|||
}
|
||||
};
|
||||
|
||||
const handleAllCounter = () => {
|
||||
const handleAllCounterChange = () => {
|
||||
if (isOwnFile) {
|
||||
return {
|
||||
ownCount: handleCounter(selected.ownCount),
|
||||
count: handleCounter(selected.count),
|
||||
ownCount: handleCounterChange(selected.ownCount),
|
||||
count: handleCounterChange(selected.count),
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
count: handleCounter(selected.count),
|
||||
count: handleCounterChange(selected.count),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
setSelected((selected) => ({
|
||||
return {
|
||||
...selected,
|
||||
[id]: checked,
|
||||
collectionID: activeCollection,
|
||||
...handleAllCounter(),
|
||||
}));
|
||||
...handleAllCounterChange(),
|
||||
};
|
||||
});
|
||||
};
|
||||
const onHoverOver = (index: number) => () => {
|
||||
setCurrentHover(index);
|
||||
|
|
Loading…
Reference in a new issue