1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

load on sync

This commit is contained in:
Kyle Spearrin
2018-04-10 22:49:19 -04:00
parent bd6eab174c
commit e31d8dd702
3 changed files with 37 additions and 8 deletions

View File

@@ -109,7 +109,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
switch (message.command) { switch (message.command) {
case 'syncCompleted': case 'syncCompleted':
window.setTimeout(() => { window.setTimeout(() => {
this.load(); this.refresh();
}, 500); }, 500);
break; break;
default: default:

View File

@@ -21,6 +21,7 @@ import { CipherView } from 'jslib/models/view/cipherView';
import { CipherService } from 'jslib/abstractions/cipher.service'; import { CipherService } from 'jslib/abstractions/cipher.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { SyncService } from 'jslib/abstractions/sync.service';
import { AutofillService } from '../../services/abstractions/autofill.service'; import { AutofillService } from '../../services/abstractions/autofill.service';
@@ -46,25 +47,26 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
showPopout = true; showPopout = true;
disableSearch = false; disableSearch = false;
loaded = false; loaded = false;
loadedTimeout: number;
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,
private analytics: Angulartics2, private toasterService: ToasterService, private analytics: Angulartics2, private toasterService: ToasterService,
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 changeDetectorRef: ChangeDetectorRef, private syncService: SyncService) {
this.inSidebar = popupUtilsService.inSidebar(window); this.inSidebar = popupUtilsService.inSidebar(window);
this.showPopout = !this.inSidebar && !platformUtilsService.isSafari(); this.showPopout = !this.inSidebar && !platformUtilsService.isSafari();
this.disableSearch = platformUtilsService.isEdge(); this.disableSearch = platformUtilsService.isEdge();
} }
ngOnInit() { async ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => { this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
this.ngZone.run(async () => { this.ngZone.run(async () => {
switch (message.command) { switch (message.command) {
case 'syncCompleted': case 'syncCompleted':
if (this.loaded) { if (this.loaded) {
setTimeout(() => { window.setTimeout(() => {
this.load(); this.load();
}, 500); }, 500);
} }
@@ -78,6 +80,12 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
}); });
} }
break; break;
case 'syncCompleted':
console.log('sync complete : ' + message.successfully);
if (message.successfully) {
await this.load();
}
break;
default: default:
break; break;
} }
@@ -86,10 +94,19 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
}) })
}); });
this.load(); if (!this.syncService.syncInProgress) {
await this.load();
} else {
this.loadedTimeout = window.setTimeout(async () => {
if (!this.loaded) {
await this.load();
}
}, 10000);
}
} }
ngOnDestroy() { ngOnDestroy() {
window.clearTimeout(this.loadedTimeout);
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId); this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
} }

View File

@@ -20,6 +20,7 @@ import { CollectionService } from 'jslib/abstractions/collection.service';
import { CipherService } from 'jslib/abstractions/cipher.service'; import { CipherService } from 'jslib/abstractions/cipher.service';
import { FolderService } from 'jslib/abstractions/folder.service'; import { FolderService } from 'jslib/abstractions/folder.service';
import { StateService } from 'jslib/abstractions/state.service'; import { StateService } from 'jslib/abstractions/state.service';
import { SyncService } from 'jslib/abstractions/sync.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
@@ -44,12 +45,14 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
showNoFolderCiphers = false; showNoFolderCiphers = false;
searchText: string; searchText: string;
state: any; state: any;
loadedTimeout: number;
constructor(collectionService: CollectionService, folderService: FolderService, constructor(collectionService: CollectionService, folderService: FolderService,
private cipherService: CipherService, private router: Router, private cipherService: CipherService, private router: Router,
private ngZone: NgZone, private broadcasterService: BroadcasterService, private ngZone: NgZone, private broadcasterService: BroadcasterService,
private changeDetectorRef: ChangeDetectorRef, private route: ActivatedRoute, private changeDetectorRef: ChangeDetectorRef, private route: ActivatedRoute,
private stateService: StateService, private popupUtils: PopupUtilsService) { private stateService: StateService, private popupUtils: PopupUtilsService,
private syncService: SyncService) {
super(collectionService, folderService); super(collectionService, folderService);
} }
@@ -80,12 +83,21 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
this.searchText = params.searchText; this.searchText = params.searchText;
} }
this.load(); if (!this.syncService.syncInProgress) {
window.setTimeout(() => this.popupUtils.setContentScrollY(window, this.state.scrollY), 0); this.load();
window.setTimeout(() => this.popupUtils.setContentScrollY(window, this.state.scrollY), 0);
} else {
this.loadedTimeout = window.setTimeout(async () => {
if (!this.loaded) {
await this.load();
}
}, 10000);
}
}); });
} }
ngOnDestroy() { ngOnDestroy() {
window.clearTimeout(this.loadedTimeout);
this.saveState(); this.saveState();
this.broadcasterService.unsubscribe(ComponentId); this.broadcasterService.unsubscribe(ComponentId);
} }