Skip to content

Commit

Permalink
Compare entries with stable stringify #3339
Browse files Browse the repository at this point in the history
  • Loading branch information
fritschldwg committed Jan 9, 2024
1 parent e9a7b98 commit 95f9691
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import stringify from "safe-stable-stringify"
import { Injectable } from "@angular/core"
import { State, Store } from "@ngrx/store"
import { createEffect } from "@ngrx/effects"

import { map, pairwise, withLatestFrom } from "rxjs"

import { visibleFileStatesSelector } from "../../selectors/visibleFileStates.selector"
import { codeMapNodesSelector } from "../../selectors/accumulatedData/codeMapNodes.selector"
import { setAmountOfTopLabels } from "../../store/appSettings/amountOfTopLabels/amountOfTopLabels.actions"
import { getNumberOfTopLabels } from "./getNumberOfTopLabels"
import { State, Store } from "@ngrx/store"
import { CcState } from "../../../codeCharta.model"

@Injectable()
Expand All @@ -18,7 +19,7 @@ export class UpdateVisibleTopLabelsEffect {
pairwise(),
withLatestFrom(this.store.select(codeMapNodesSelector)),
map(([[previousVisibleFileStates, currentVisibleFileStates], codeMapNodes]) => {
const isUnchanged = JSON.stringify(previousVisibleFileStates) === JSON.stringify(currentVisibleFileStates)
const isUnchanged = stringify(previousVisibleFileStates) === stringify(currentVisibleFileStates)
const amountOfTopLabels = isUnchanged
? this.state.getValue().appSettings.amountOfTopLabels
: getNumberOfTopLabels(codeMapNodes)
Expand Down
6 changes: 4 additions & 2 deletions visualization/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions visualization/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"pako": "^2.0.4",
"percent-round": "^2.2.1",
"rxjs": "^7.5.1",
"safe-stable-stringify": "^2.4.3",
"shelljs": "^0.8.4",
"three": "^0.126.1",
"three-orbit-controls": "^82.1.0",
Expand Down

0 comments on commit 95f9691

Please sign in to comment.