High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(web): timeline multi select group state (#26180)
Michel Heusschen34eb2e141086
diff --git a/web/src/lib/components/timeline/Timeline.svelte b/web/src/lib/components/timeline/Timeline.svelteindex f63fe29f4e..9c07bff828 100644--- a/web/src/lib/components/timeline/Timeline.svelte+++ b/web/src/lib/components/timeline/Timeline.svelte@@ -443,54 +443,50 @@assetInteraction.clearAssetSelectionCandidates();if (assetInteraction.assetSelectionStart && rangeSelection) {- let startBucket = timelineManager.getMonthGroupByAssetId(assetInteraction.assetSelectionStart.id);- let endBucket = timelineManager.getMonthGroupByAssetId(asset.id);+ const startBucket = timelineManager.getMonthGroupByAssetId(assetInteraction.assetSelectionStart.id);+ const endBucket = timelineManager.getMonthGroupByAssetId(asset.id);- if (startBucket === null || endBucket === null) {+ if (!startBucket || !endBucket) {return;}+ const monthGroups = timelineManager.months;+ const startBucketIndex = monthGroups.indexOf(startBucket);+ const endBucketIndex = monthGroups.indexOf(endBucket);++ if (startBucketIndex === -1 || endBucketIndex === -1) {+ return;+ }++ const rangeStartIndex = Math.min(startBucketIndex, endBucketIndex);+ const rangeEndIndex = Math.max(startBucketIndex, endBucketIndex);+// Select/deselect assets in range (start,end)- let started = false;- for (const monthGroup of timelineManager.months) {- if (monthGroup === endBucket) {- break;- }- if (started) {- await timelineManager.loadMonthGroup(monthGroup.yearMonth);- for (const asset of monthGroup.assetsIterator()) {- if (deselect) {- assetInteraction.removeAssetFromMultiselectGroup(asset.id);- } else {- handleSelectAsset(asset);- }+ for (let index = rangeStartIndex + 1; index < rangeEndIndex; index++) {+ const monthGroup = monthGroups[index];+ await timelineManager.loadMonthGroup(monthGroup.yearMonth);+ for (const monthAsset of monthGroup.assetsIterator()) {+ if (deselect) {+ assetInteraction.removeAssetFromMultiselectGroup(monthAsset.id);+ } else {+ handleSelectAsset(monthAsset);}}- if (monthGroup === startBucket) {- started = true;- }}// Update date group selection in range [start,end]- started = false;- for (const monthGroup of timelineManager.months) {- if (monthGroup === startBucket) {- started = true;- }- if (started) {- // Split month group into day groups and check each group- for (const dayGroup of monthGroup.dayGroups) {- const dayGroupTitle = dayGroup.groupTitle;- if (dayGroup.getAssets().every((a) => assetInteraction.hasSelectedAsset(a.id))) {- assetInteraction.addGroupToMultiselectGroup(dayGroupTitle);- } else {- assetInteraction.removeGroupFromMultiselectGroup(dayGroupTitle);- }+ for (let index = rangeStartIndex; index <= rangeEndIndex; index++) {+ const monthGroup = monthGroups[index];++ // Split month group into day groups and check each group+ for (const dayGroup of monthGroup.dayGroups) {+ const dayGroupTitle = dayGroup.groupTitle;+ if (dayGroup.getAssets().every((a) => assetInteraction.hasSelectedAsset(a.id))) {+ assetInteraction.addGroupToMultiselectGroup(dayGroupTitle);+ } else {+ assetInteraction.removeGroupFromMultiselectGroup(dayGroupTitle);}}- if (monthGroup === endBucket) {- break;- }}}