1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-07 09:31:31 +01:00

allow reloading of current tab

This commit is contained in:
Kyle Spearrin 2019-08-19 09:17:40 -04:00
parent aa0bfd3b45
commit 05684b3b03
2 changed files with 16 additions and 8 deletions

View File

@ -219,6 +219,7 @@ const routes: Routes = [
component: CurrentTabComponent, component: CurrentTabComponent,
canActivate: [AuthGuardService], canActivate: [AuthGuardService],
data: { state: 'tabs_current' }, data: { state: 'tabs_current' },
runGuardsAndResolvers: 'always',
}, },
{ {
path: 'vault', path: 'vault',
@ -265,6 +266,7 @@ export class NoRouteReuseStrategy implements RouteReuseStrategy {
@NgModule({ @NgModule({
imports: [RouterModule.forRoot(routes, { imports: [RouterModule.forRoot(routes, {
useHash: true, useHash: true,
onSameUrlNavigation: 'reload',
/*enableTracing: true,*/ /*enableTracing: true,*/
})], })],
exports: [RouterModule], exports: [RouterModule],

View File

@ -8,9 +8,12 @@ import {
import { import {
ActivatedRoute, ActivatedRoute,
NavigationEnd,
Router, Router,
} from '@angular/router'; } from '@angular/router';
import { Subscription } from 'rxjs';
import { ToasterService } from 'angular2-toaster'; import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2'; import { Angulartics2 } from 'angulartics2';
@ -61,6 +64,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
private totpTimeout: number; private totpTimeout: number;
private loadedTimeout: number; private loadedTimeout: number;
private searchTimeout: number; private searchTimeout: number;
private navSubscription: Subscription;
constructor(private platformUtilsService: PlatformUtilsService, private cipherService: CipherService, constructor(private platformUtilsService: PlatformUtilsService, private cipherService: CipherService,
private popupUtilsService: PopupUtilsService, private autofillService: AutofillService, private popupUtilsService: PopupUtilsService, private autofillService: AutofillService,
@ -68,25 +72,27 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
private i18nService: I18nService, private router: Router, private i18nService: I18nService, private router: Router,
private ngZone: NgZone, private broadcasterService: BroadcasterService, private ngZone: NgZone, private broadcasterService: BroadcasterService,
private changeDetectorRef: ChangeDetectorRef, private syncService: SyncService, private changeDetectorRef: ChangeDetectorRef, private syncService: SyncService,
private searchService: SearchService, private storageService: StorageService, private searchService: SearchService, private storageService: StorageService) {
route: ActivatedRoute) { this.navSubscription = this.router.events.subscribe(async (e: any) => {
route.params.subscribe((val) => { // If it is a NavigationEnd event re-initialize the component
console.log('route.params.subscribe'); if (e instanceof NavigationEnd) {
if (platformUtilsService.getDevice() === DeviceType.SafariExtension) { console.log('nav end');
console.log(val); console.log(e);
this.init(); await this.init();
} }
}); });
} }
async ngOnInit() { async ngOnInit() {
console.log('ngOnInit'); console.log('ngOnInit');
await this.init();
} }
ngOnDestroy() { ngOnDestroy() {
window.clearTimeout(this.loadedTimeout); window.clearTimeout(this.loadedTimeout);
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId); this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
if (this.navSubscription != null) {
this.navSubscription.unsubscribe();
}
} }
async refresh() { async refresh() {