Skip to content

Commit

Permalink
fix: almost reduce autoFitTo file selection change
Browse files Browse the repository at this point in the history
ref #2318
  • Loading branch information
shaman-apprentice committed Aug 13, 2022
1 parent 27469fe commit 70cf60d
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject, Injectable } from "@angular/core"
import { asyncScheduler, combineLatest, filter, switchMap, tap, throttleTime } from "rxjs"
import { asyncScheduler, combineLatest, concatMap, filter, take, tap, throttleTime } from "rxjs"
import { CodeMapRenderService } from "../../../ui/codeMap/codeMap.render.service"
import { ThreeOrbitControlsService } from "../../../ui/codeMap/threeViewer/threeOrbitControlsService"
import { ThreeRendererService } from "../../../ui/codeMap/threeViewer/threeRendererService"
Expand Down Expand Up @@ -114,14 +114,13 @@ export class RenderCodeMapEffect {
{ dispatch: false }
)

private renderedAfterFileSelectionChange$ = this.store.select(visibleFileStatesSelector).pipe(switchMap(() => this.renderCodeMap$))

autoFitCodeMapOnFileSelectionChange$ = createEffect(
() =>
this.renderedAfterFileSelectionChange$.pipe(
this.store.select(visibleFileStatesSelector).pipe(
filter(() => resetCameraIfNewFileIsLoadedSelector(this.state.getValue())),
concatMap(() => this.renderCodeMap$.pipe(take(1))),
tap(() => {
ThreeOrbitControlsService.instance.autoFitTo()
ThreeOrbitControlsService.instance?.autoFitTo()
})
),
{ dispatch: false }
Expand Down

0 comments on commit 70cf60d

Please sign in to comment.