From 0c93860816dba4c01065e2e61188e1f8a0b801dc Mon Sep 17 00:00:00 2001 From: garrettmills Date: Wed, 23 Dec 2020 21:14:43 -0600 Subject: [PATCH] Fix page reload navigation and add more debugging --- src/app/app.component.ts | 8 ++++++++ src/app/pages/editor/editor.page.ts | 4 ++++ src/app/service/navigation.service.ts | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 8dd6e0e..86e4cd7 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -192,6 +192,8 @@ export class AppComponent implements OnInit { const id = node.data.id; const nodeId = node.data.node_id; if ( !node.data.virtual ) { + debug('Navigating editor to node:', {id, nodeId}); + this.currentPageId = id; this.router.navigate(['/editor', { id, ...(nodeId ? { node_id: nodeId } : {}) }]); } @@ -608,6 +610,12 @@ export class AppComponent implements OnInit { }); this.navService.navigationRequest$.subscribe(pageId => { + debug('Page navigation request: ', {pageId}); + if ( !pageId ) { + debug('Empty page ID. Will not navigate.'); + return; + } + this.currentPageId = pageId; this.router.navigate(['/editor', { id: pageId }]); }); diff --git a/src/app/pages/editor/editor.page.ts b/src/app/pages/editor/editor.page.ts index fd5ca4a..0618f7a 100644 --- a/src/app/pages/editor/editor.page.ts +++ b/src/app/pages/editor/editor.page.ts @@ -43,6 +43,8 @@ export class EditorPage implements OnInit { protected modals: ModalController, public readonly editorService: EditorService, ) { + debug('Constructed editor page.'); + this.route.params.subscribe(params => { this.pageId = params.id; debug('Got page ID from route:', this.pageId, params); @@ -54,6 +56,8 @@ export class EditorPage implements OnInit { ngOnInit() {} ionViewDidEnter() { + debug('Ion view did enter editor page.'); + if ( this.pageId ) { this.editorService.startEditing(this.pageId, this.version); } else if ( !this.hosted ) { diff --git a/src/app/service/navigation.service.ts b/src/app/service/navigation.service.ts index 476d214..20c7156 100644 --- a/src/app/service/navigation.service.ts +++ b/src/app/service/navigation.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import {BehaviorSubject} from 'rxjs'; +import {debug} from '../utility'; @Injectable({ providedIn: 'root' @@ -15,6 +16,9 @@ export class NavigationService { } requestNavigation(pageId: string) { + debug('Requesting page navigation:', pageId); + debug('Page navigation trace', new Error()); + this.navigationRequest$.next(pageId); } }