Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: trigger auto fit only once after file selection #3109

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/)
### Fixed 🐞

- Fix broken link to Custom View documentation [#3101](https://github.com/MaibornWolff/codecharta/pull/3101)
- Don't re-center map after every state change like changing area metric [#3109](https://github.com/MaibornWolff/codecharta/pull/3109)

### Chore 👨‍💻 👩‍💻

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ describe("autoFitCodeMapOnFileSelectionChangeEffect", () => {
expect(mockedAutoFitTo).toHaveBeenCalledTimes(1)
})

it("should switch and not concat inner observable, so auto fit map gets called only once", () => {
mockedResetCameraIfNewFileIsLoadedSelector.mockImplementation(() => true)
mockedVisibleFileStates$.next("")
mockedFocusedNodePath$.next("")
mockedRenderCodeMap$.next("")
expect(mockedAutoFitTo).toHaveBeenCalledTimes(1)

mockedRenderCodeMap$.next("")
expect(mockedAutoFitTo).toHaveBeenCalledTimes(1)
})

it("should do nothing when 'reset camera if new file is loaded' is deactivated", () => {
mockedResetCameraIfNewFileIsLoadedSelector.mockImplementation(() => false)
mockedVisibleFileStates$.next("")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject, Injectable } from "@angular/core"
import { concatMap, filter, skip, take, tap, combineLatest } from "rxjs"
import { switchMap, filter, skip, take, tap, combineLatest } from "rxjs"
import { ThreeOrbitControlsService } from "../../../ui/codeMap/threeViewer/threeOrbitControls.service"
import { createEffect } from "../../angular-redux/effects/createEffect"
import { State } from "../../angular-redux/state"
Expand Down Expand Up @@ -28,7 +28,7 @@ export class AutoFitCodeMapEffect {
]).pipe(
skip(1), // initial map load is already fitted
filter(() => resetCameraIfNewFileIsLoadedSelector(this.state.getValue())),
concatMap(() => this.renderCodeMapEffect.renderCodeMap$.pipe(take(1))),
switchMap(() => this.renderCodeMapEffect.renderCodeMap$.pipe(take(1))),
tap(() => {
this.threeOrbitControlsService.autoFitTo()
})
Expand Down