1- import { distinctUntilChanged, take, withLatestFrom, delay } from 'rxjs/operators';
2- import { DOCUMENT } from '@angular/common';
1+ import { distinctUntilChanged, map, switchMap, take, withLatestFrom } from 'rxjs/operators';
2+ import { DOCUMENT, isPlatformBrowser } from '@angular/common';
33import {
44 AfterViewInit,
55 ChangeDetectionStrategy,
@@ -9,12 +9,7 @@ import {
99 OnInit,
1010 PLATFORM_ID,
1111} from '@angular/core';
12- import {
13- NavigationCancel,
14- NavigationEnd,
15- NavigationStart,
16- Router,
17- } from '@angular/router';
12+ import { NavigationCancel, NavigationEnd, NavigationStart, Router, RouterEvent, } from '@angular/router';
1813
1914import { BehaviorSubject, Observable } from 'rxjs';
2015import { select, Store } from '@ngrx/store';
@@ -31,6 +26,10 @@ import { models } from './core/core.module';
3126import { ThemeService } from './shared/theme-support/theme.service';
3227import { IdleModalComponent } from './shared/idle-modal/idle-modal.component';
3328import { distinctNext } from './core/shared/distinct-next';
29+ import { RouteService } from './core/services/route.service';
30+ import { getEditItemPageRoute, getWorkflowItemModuleRoute, getWorkspaceItemModuleRoute } from './app-routing-paths';
31+ import { SocialService } from './social/social.service';
32+ import { DatadogRumService } from './shared/datadog-rum/datadog-rum.service';
3433
3534@Component({
3635 selector: 'ds-app',
@@ -61,6 +60,8 @@ export class AppComponent implements OnInit, AfterViewInit {
6160 * Whether or not the idle modal is is currently open
6261 */
6362 idleModalOpen: boolean;
63+
64+
6465 /**
6566 * In order to show sharing component only in csr
6667 */
@@ -75,15 +76,18 @@ export class AppComponent implements OnInit, AfterViewInit {
7576 private store: Store<HostWindowState>,
7677 private authService: AuthService,
7778 private router: Router,
79+ private routeService: RouteService,
7880 private cssService: CSSVariableService,
7981 private modalService: NgbModal,
8082 private modalConfig: NgbModalConfig,
83+ private socialService: SocialService,
84+ private datadogRumService: DatadogRumService
8185 ) {
8286 this.notificationOptions = environment.notifications;
87+ this.browserPlatform = isPlatformBrowser(this.platformId);
8388
8489 /* Use models object so all decorators are actually called */
8590 this.models = models;
86- this.browserPlatform = this.platformId;
8791
8892 if (this.browserPlatform) {
8993 this.trackIdleModal();
@@ -92,6 +96,8 @@ export class AppComponent implements OnInit, AfterViewInit {
9296 this.isThemeLoading$ = this.themeService.isThemeLoading$;
9397
9498 this.storeCSSVariables();
99+
100+ this.socialService.initialize();
95101 }
96102
97103 ngOnInit() {
@@ -111,6 +117,8 @@ export class AppComponent implements OnInit, AfterViewInit {
111117 );
112118
113119 this.dispatchWindowSize(this._window.nativeWindow.innerWidth, this._window.nativeWindow.innerHeight);
120+
121+ this.datadogRumService.initDatadogRum();
114122 }
115123
116124 private storeCSSVariables() {
@@ -120,11 +128,16 @@ export class AppComponent implements OnInit, AfterViewInit {
120128
121129 ngAfterViewInit() {
122130 this.router.events.pipe(
123- // delay(0) to prevent "Expression has changed after it was checked" errors
124- delay(0)
125- ).subscribe((event) => {
131+ switchMap((event: RouterEvent) => this.routeService.getCurrentUrl().pipe(
132+ take(1),
133+ map((currentUrl) => [currentUrl, event])
134+ ))
135+ ).subscribe(([currentUrl, event]: [string, RouterEvent]) => {
126136 if (event instanceof NavigationStart) {
127- distinctNext(this.isRouteLoading$, true);
137+ if (!(currentUrl.startsWith(getEditItemPageRoute()) || currentUrl.startsWith(getWorkspaceItemModuleRoute()) || currentUrl.startsWith(getWorkflowItemModuleRoute()))) {
138+ distinctNext(this.isRouteLoading$, true);
139+ }
140+ // distinctNext(this.isRouteLoading$, true);
128141 } else if (
129142 event instanceof NavigationEnd ||
130143 event instanceof NavigationCancel
0 commit comments