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) {
case 'syncCompleted':
window.setTimeout(() => {
this.load();
this.refresh();
}, 500);
break;
default:

View File

@ -21,6 +21,7 @@ import { CipherView } from 'jslib/models/view/cipherView';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { SyncService } from 'jslib/abstractions/sync.service';
import { AutofillService } from '../../services/abstractions/autofill.service';
@ -46,25 +47,26 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
showPopout = true;
disableSearch = false;
loaded = false;
loadedTimeout: number;
constructor(private platformUtilsService: PlatformUtilsService, private cipherService: CipherService,
private popupUtilsService: PopupUtilsService, private autofillService: AutofillService,
private analytics: Angulartics2, private toasterService: ToasterService,
private i18nService: I18nService, private router: Router,
private ngZone: NgZone, private broadcasterService: BroadcasterService,
private changeDetectorRef: ChangeDetectorRef) {
private changeDetectorRef: ChangeDetectorRef, private syncService: SyncService) {
this.inSidebar = popupUtilsService.inSidebar(window);
this.showPopout = !this.inSidebar && !platformUtilsService.isSafari();
this.disableSearch = platformUtilsService.isEdge();
}
ngOnInit() {
async ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
this.ngZone.run(async () => {
switch (message.command) {
case 'syncCompleted':
if (this.loaded) {
setTimeout(() => {
window.setTimeout(() => {
this.load();
}, 500);
}
@ -78,6 +80,12 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
});
}
break;
case 'syncCompleted':
console.log('sync complete : ' + message.successfully);
if (message.successfully) {
await this.load();
}
break;
default:
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() {
window.clearTimeout(this.loadedTimeout);
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 { FolderService } from 'jslib/abstractions/folder.service';
import { StateService } from 'jslib/abstractions/state.service';
import { SyncService } from 'jslib/abstractions/sync.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
@ -44,12 +45,14 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
showNoFolderCiphers = false;
searchText: string;
state: any;
loadedTimeout: number;
constructor(collectionService: CollectionService, folderService: FolderService,
private cipherService: CipherService, private router: Router,
private ngZone: NgZone, private broadcasterService: BroadcasterService,
private changeDetectorRef: ChangeDetectorRef, private route: ActivatedRoute,
private stateService: StateService, private popupUtils: PopupUtilsService) {
private stateService: StateService, private popupUtils: PopupUtilsService,
private syncService: SyncService) {
super(collectionService, folderService);
}
@ -80,12 +83,21 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
this.searchText = params.searchText;
}
this.load();
window.setTimeout(() => this.popupUtils.setContentScrollY(window, this.state.scrollY), 0);
if (!this.syncService.syncInProgress) {
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() {
window.clearTimeout(this.loadedTimeout);
this.saveState();
this.broadcasterService.unsubscribe(ComponentId);
}