Skip to content

Commit

Permalink
Hotfix for sourceExclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbyul-here committed Sep 18, 2024
1 parent 0470861 commit bf3088a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/scripts/components/common/catalog/catalog-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,23 @@ function CatalogContent({

const newSelectedIds = selectedIds.includes(id) ? selectedIds.filter((i) => i !== id) : [...selectedIds, id];

const selectedIdsWithParentData = getSelectedIdsWithParentData(newSelectedIds);
let selectedIdsWithParentData = getSelectedIdsWithParentData(newSelectedIds);

// @NOTE: Check if the new exclusiveSource is selected. Filter out the old one.
if (exclusiveSource !== exclusiveSourceSelected) {
selectedIdsWithParentData = selectedIdsWithParentData.filter(d => d.sourceExclusive !== exclusiveSourceSelected)
}

const relevantIdsBasedOnExclusion = filterRelevantIdsBasedOnExclusion(selectedIdsWithParentData, exclusiveSource && sourceIds?.includes(exclusiveSource));

let relevantIdsBasedOnPreviousExclusion

if (exclusiveSource && sourceIds?.includes(exclusiveSource)) {
setExclusiveSourceSelected(exclusiveSource);
} else {
setExclusiveSourceSelected(null);
}

const relevantIdsBasedOnExclusion = filterRelevantIdsBasedOnExclusion(selectedIdsWithParentData, exclusiveSource && sourceIds?.includes(exclusiveSource));

setSelectedIds(newSelectedIds.filter((id) => relevantIdsBasedOnExclusion.includes(id)));
}, [selectedIds, setSelectedIds]);

Expand Down

0 comments on commit bf3088a

Please sign in to comment.