Skip to content

Commit

Permalink
Deep copy cuts, so that they work correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardMoyse committed Nov 8, 2024
1 parent 769f89e commit 6127251
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/phoenix-event-display/src/loaders/phoenix-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CoordinateHelper } from '../helpers/coordinate-helper.js';
import { getLabelTitle } from '../helpers/labels.js';
import { DatGUIMenuUI } from '../managers/ui-manager/dat-gui-ui.js';
import { PhoenixMenuUI } from '../managers/ui-manager/phoenix-menu/phoenix-menu-ui.js';
import * as _ from 'lodash';

/**
* Loader for processing and loading an event.
Expand Down Expand Up @@ -461,6 +462,8 @@ export class PhoenixLoader implements EventDataLoader {
this.ui.addEventDataTypeFolder(typeName);

for (const collectionName of collectionsList) {
const newCuts = _.cloneDeep(cuts);
// Make a new array ^, otherwise we reuse the same cuts for each collection
const objectCollection = object[collectionName];
console.log(
`${typeName} collection ${collectionName} has ${objectCollection.length} constituents.`,
Expand All @@ -480,8 +483,11 @@ export class PhoenixLoader implements EventDataLoader {
concatonateObjs,
);

cuts = cuts?.filter((cut) => cut.field in objectCollection[0]);
this.ui.addCollection(typeName, collectionName, cuts);
// collectionCuts is shallow copy
const collectionCuts = newCuts?.filter(
(cut) => cut.field in objectCollection[0],
);
this.ui.addCollection(typeName, collectionName, collectionCuts);
}

const eventDataTypeFolderDatGUI = this.ui
Expand Down

0 comments on commit 6127251

Please sign in to comment.