Skip to content

Commit

Permalink
remove duplicate items from the Workbench items
Browse files Browse the repository at this point in the history
  • Loading branch information
sixlighthouses committed Jul 24, 2023
1 parent b3011dd commit 4a2871f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Models/Workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import LayerOrderingTraits from "../Traits/TraitsClasses/LayerOrderingTraits";
import CommonStrata from "./Definition/CommonStrata";
import hasTraits from "./Definition/hasTraits";
import { BaseModel } from "./Definition/Model";
import { uniqueId } from "lodash-es";

const keepOnTop = (model: BaseModel) =>
hasTraits(model, LayerOrderingTraits, "keepOnTop") && model.keepOnTop;
Expand All @@ -34,7 +35,13 @@ export default class Workbench {
return this._items.map(dereferenceModel);
}
set items(items: readonly BaseModel[]) {
this._items.spliceWithArray(0, this._items.length, items.slice());
console.log(items);

// remove duplicate items from items based on uniqueId
const uniqueItems = items.filter((item, index, self) => {
return index === self.findIndex((t) => t.uniqueId === item.uniqueId);
});
this._items.spliceWithArray(0, this._items.length, uniqueItems.slice());
}

/**
Expand Down

0 comments on commit 4a2871f

Please sign in to comment.