1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-02 08:40:08 +01:00

reload when on same page too

This commit is contained in:
Kyle Spearrin 2019-08-16 20:59:54 -04:00
parent 206530a940
commit a3f76cfd3a
3 changed files with 66 additions and 47 deletions

2
jslib

@ -1 +1 @@
Subproject commit 640c44820a2e26b6e34591b59bc168a6eb455e83
Subproject commit 1f98a2ebcb1f08dca39047fe77d8dea4bb1a67dc

View File

@ -129,7 +129,7 @@ export class AppComponent implements OnInit {
}
} else if (msg.command === 'reloadPopup') {
this.ngZone.run(() => {
this.router.navigate(['/']);
this.router.navigate(['/', { queryParams: { reload: true } }]);
});
} else {
msg.webExtSender = sender;

View File

@ -5,7 +5,11 @@ import {
OnDestroy,
OnInit,
} from '@angular/core';
import { Router } from '@angular/router';
import {
ActivatedRoute,
Router,
} from '@angular/router';
import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
@ -15,6 +19,7 @@ import { BrowserApi } from '../../browser/browserApi';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { CipherType } from 'jslib/enums/cipherType';
import { DeviceType } from 'jslib/enums/deviceType';
import { CipherView } from 'jslib/models/view/cipherView';
@ -63,52 +68,20 @@ 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) { }
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();
}
});
}
async ngOnInit() {
this.showLeftHeader = this.searchTypeSearch = !this.platformUtilsService.isSafari();
this.inSidebar = this.popupUtilsService.inSidebar(window);
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
this.ngZone.run(async () => {
switch (message.command) {
case 'syncCompleted':
if (this.loaded) {
window.setTimeout(() => {
this.load();
}, 500);
}
break;
case 'collectPageDetailsResponse':
if (message.sender === BroadcasterSubscriptionId) {
this.pageDetails.push({
frameId: message.webExtSender.frameId,
tab: message.tab,
details: message.details,
});
}
break;
default:
break;
}
this.changeDetectorRef.detectChanges();
});
});
if (!this.syncService.syncInProgress) {
await this.load();
} else {
this.loadedTimeout = window.setTimeout(async () => {
if (!this.loaded) {
await this.load();
}
}, 5000);
}
window.setTimeout(() => {
document.getElementById('search').focus();
}, 100);
console.log('ngOnInit');
this.init();
}
ngOnDestroy() {
@ -184,6 +157,52 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
}, 200);
}
private init() {
this.showLeftHeader = this.searchTypeSearch = !this.platformUtilsService.isSafari();
this.inSidebar = this.popupUtilsService.inSidebar(window);
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
this.ngZone.run(async () => {
switch (message.command) {
case 'syncCompleted':
if (this.loaded) {
window.setTimeout(() => {
this.load();
}, 500);
}
break;
case 'collectPageDetailsResponse':
if (message.sender === BroadcasterSubscriptionId) {
this.pageDetails.push({
frameId: message.webExtSender.frameId,
tab: message.tab,
details: message.details,
});
}
break;
default:
break;
}
this.changeDetectorRef.detectChanges();
});
});
if (!this.syncService.syncInProgress) {
await this.load();
} else {
this.loadedTimeout = window.setTimeout(async () => {
if (!this.loaded) {
await this.load();
}
}, 5000);
}
window.setTimeout(() => {
document.getElementById('search').focus();
}, 100);
}
private async load() {
const tab = await BrowserApi.getTabFromCurrentWindow();
if (tab != null) {