sel: always select clicked photo

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/953/head
Varun Patil 2023-11-26 19:10:37 -08:00
parent 366c6dc5e2
commit 2e70655c31
1 changed files with 17 additions and 8 deletions

View File

@ -652,6 +652,9 @@ export default defineComponent({
const pIdx = pRow.photos?.indexOf(photo) ?? -1; const pIdx = pRow.photos?.indexOf(photo) ?? -1;
if (pIdx === -1) return; if (pIdx === -1) return;
// Set of dayIds to update at the end of this method
const touchedDays = new Set<number>();
/** /**
* @brief Look behind for a selected photo. * @brief Look behind for a selected photo.
* @returns the list of photos behind the current photo upto * @returns the list of photos behind the current photo upto
@ -683,10 +686,15 @@ export default defineComponent({
} }
}; };
// Set of dayIds to update /** Select or de-select a photo and update touchedDays */
const touchedDays = new Set<number>(); const selfun = (p: IPhoto, val: boolean) => {
this.selectPhoto(p, val, true);
touchedDays.add(p.dayid);
};
const select = (p: IPhoto) => selfun(p, true);
const deselect = (p: IPhoto) => selfun(p, false);
// Select everything behind // Select everything behind if found
const behind = lookBehind(); const behind = lookBehind();
if (behind) { if (behind) {
// Clear everything in front in this day // Clear everything in front in this day
@ -694,23 +702,24 @@ export default defineComponent({
const pdIdx = detail.indexOf(photo); const pdIdx = detail.indexOf(photo);
for (let i = pdIdx + 1; i < detail.length; i++) { for (let i = pdIdx + 1; i < detail.length; i++) {
if (detail[i].flag & this.c.FLAG_SELECTED) { if (detail[i].flag & this.c.FLAG_SELECTED) {
this.selectPhoto(detail[i], false, true); deselect(detail[i]);
} }
} }
// De-select everything else in front (other days) // De-select everything else in front (other days)
for (const [_, p] of this.selection) { for (const [_, p] of this.selection) {
if (this.isreverse ? p.dayid > photo.dayid : p.dayid < photo.dayid) { if (this.isreverse ? p.dayid > photo.dayid : p.dayid < photo.dayid) {
this.selectPhoto(p, false, true); deselect(p);
touchedDays.add(p.dayid);
} }
} }
// Select everything behind upto the selected photo // Select everything behind upto the selected photo
for (const p of behind) { for (const p of behind) {
this.selectPhoto(p, true, true); select(p);
touchedDays.add(p.dayid);
} }
} else {
// Always select the photo that was clicked
select(photo);
} }
// Force update for all days that were touched // Force update for all days that were touched