fix: duplicate segmentation entries on layout switch (#5458)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
1 parent
71c16615d1
commit
9e951e8800
2 files changed
+111
-7
No files matched your search
@@ -152,15 +152,27 @@ export function useViewportSegmentations({
|
||||
|
||||
const representations = segmentationService.getSegmentationRepresentations(viewportId);
|
||||
|
||||
const newSegmentationsWithRepresentations = representations.map(representation => {
|
||||
const segmentation = segmentationService.getSegmentation(representation.segmentationId);
|
||||
const mappedSegmentation = mapSegmentationToDisplay(segmentation, customizationService);
|
||||
return {
|
||||
representation,
|
||||
segmentation: mappedSegmentation,
|
||||
};
|
||||
// Deduplicate representations by segmentationId to prevent showing
|
||||
// the same segmentation multiple times in the panel when it has
|
||||
// multiple representation types (e.g., labelmap and surface)
|
||||
const uniqueSegmentationMap = new Map();
|
||||
representations.forEach(representation => {
|
||||
if (!uniqueSegmentationMap.has(representation.segmentationId)) {
|
||||
uniqueSegmentationMap.set(representation.segmentationId, representation);
|
||||
}
|
||||
});
|
||||
|
||||
const newSegmentationsWithRepresentations = Array.from(uniqueSegmentationMap.values()).map(
|
||||
representation => {
|
||||
const segmentation = segmentationService.getSegmentation(representation.segmentationId);
|
||||
const mappedSegmentation = mapSegmentationToDisplay(segmentation, customizationService);
|
||||
return {
|
||||
representation,
|
||||
segmentation: mappedSegmentation,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
setSegmentationsWithRepresentations({
|
||||
segmentationsWithRepresentations: newSegmentationsWithRepresentations,
|
||||
disabled: false,
|
||||
|
||||
Reference in new issue
Block a user