From 05684b3b03ce2da90e06f9e85a492586ac2f0619 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 19 Aug 2019 09:17:40 -0400 Subject: [PATCH] allow reloading of current tab --- src/popup/app-routing.module.ts | 2 ++ src/popup/vault/current-tab.component.ts | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/popup/app-routing.module.ts b/src/popup/app-routing.module.ts index a8d670931a..fe575fc771 100644 --- a/src/popup/app-routing.module.ts +++ b/src/popup/app-routing.module.ts @@ -219,6 +219,7 @@ const routes: Routes = [ component: CurrentTabComponent, canActivate: [AuthGuardService], data: { state: 'tabs_current' }, + runGuardsAndResolvers: 'always', }, { path: 'vault', @@ -265,6 +266,7 @@ export class NoRouteReuseStrategy implements RouteReuseStrategy { @NgModule({ imports: [RouterModule.forRoot(routes, { useHash: true, + onSameUrlNavigation: 'reload', /*enableTracing: true,*/ })], exports: [RouterModule], diff --git a/src/popup/vault/current-tab.component.ts b/src/popup/vault/current-tab.component.ts index 2689347365..a3f7f4e923 100644 --- a/src/popup/vault/current-tab.component.ts +++ b/src/popup/vault/current-tab.component.ts @@ -8,9 +8,12 @@ import { import { ActivatedRoute, + NavigationEnd, Router, } from '@angular/router'; +import { Subscription } from 'rxjs'; + import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; @@ -61,6 +64,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy { private totpTimeout: number; private loadedTimeout: number; private searchTimeout: number; + private navSubscription: Subscription; constructor(private platformUtilsService: PlatformUtilsService, private cipherService: CipherService, private popupUtilsService: PopupUtilsService, private autofillService: AutofillService, @@ -68,25 +72,27 @@ export class CurrentTabComponent implements OnInit, OnDestroy { private i18nService: I18nService, private router: Router, private ngZone: NgZone, private broadcasterService: BroadcasterService, private changeDetectorRef: ChangeDetectorRef, private syncService: SyncService, - private searchService: SearchService, private storageService: StorageService, - route: ActivatedRoute) { - route.params.subscribe((val) => { - console.log('route.params.subscribe'); - if (platformUtilsService.getDevice() === DeviceType.SafariExtension) { - console.log(val); - this.init(); + private searchService: SearchService, private storageService: StorageService) { + this.navSubscription = this.router.events.subscribe(async (e: any) => { + // If it is a NavigationEnd event re-initialize the component + if (e instanceof NavigationEnd) { + console.log('nav end'); + console.log(e); + await this.init(); } }); } async ngOnInit() { console.log('ngOnInit'); - await this.init(); } ngOnDestroy() { window.clearTimeout(this.loadedTimeout); this.broadcasterService.unsubscribe(BroadcasterSubscriptionId); + if (this.navSubscription != null) { + this.navSubscription.unsubscribe(); + } } async refresh() {