Skip to content

Commit

Permalink
Simplify/clarify unique vl array
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Dupuy <[email protected]>
  • Loading branch information
flo-dup committed Feb 23, 2024
1 parent e35a0a7 commit de0af48
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/single-line-diagram-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,15 @@ export class SingleLineDiagramViewer {
private addNavigationArrow() {
if (this.onNextVoltageCallback !== null) {
let navigable = this.svgMetadata?.nodes.filter((el) => el.nextVId);
let vlList = this.svgMetadata?.nodes.map((element) => element.vid);
vlList = vlList?.filter(
(element, index) =>
element !== '' && vlList?.indexOf(element) === index
);
const vlList = navigable
?.map((element) => element.vid)
.filter((vid) => vid !== '');
const vlSet = new Set(vlList);

//remove arrows if the arrow points to the current svg
navigable = navigable?.filter((element) => {
return vlList?.indexOf(element.nextVId) === -1;
});
navigable = navigable?.filter(
(element) => !vlSet.has(element.nextVId)
);

navigable?.forEach((element) => {
const elementById: HTMLElement | null =
Expand Down

0 comments on commit de0af48

Please sign in to comment.