1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

delay load while syncing

This commit is contained in:
Kyle Spearrin
2018-02-09 11:18:37 -05:00
parent 092bdb5e07
commit f80ae40b1a
5 changed files with 93 additions and 64 deletions

View File

@@ -33,6 +33,7 @@ import { CollectionView } from 'jslib/models/view/collectionView';
import { FolderView } from 'jslib/models/view/folderView';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { SyncService } from 'jslib/abstractions/sync.service';
@Component({
selector: 'app-vault',
@@ -57,7 +58,7 @@ export class VaultComponent implements OnInit {
constructor(private route: ActivatedRoute, private router: Router, private location: Location,
private componentFactoryResolver: ComponentFactoryResolver, private i18nService: I18nService,
private broadcasterService: BroadcasterService, private changeDetectorRef: ChangeDetectorRef,
private ngZone: NgZone) {
private ngZone: NgZone, private syncService: SyncService) {
}
async ngOnInit() {
@@ -92,40 +93,56 @@ export class VaultComponent implements OnInit {
});
});
this.route.queryParams.subscribe(async (params) => {
if (params.cipherId) {
const cipherView = new CipherView();
cipherView.id = params.cipherId;
if (params.action === 'edit') {
this.editCipher(cipherView);
} else {
this.viewCipher(cipherView);
}
} else if (params.action === 'add') {
this.addCipher();
}
while (this.syncService.syncInProgress) {
await new Promise((resolve) => setTimeout(resolve, 200));
}
if (params.favorites) {
this.groupingsComponent.selectedFavorites = true;
await this.filterFavorites();
} else if (params.type) {
const t = parseInt(params.type, null);
this.groupingsComponent.selectedType = t;
await this.filterCipherType(t);
} else if (params.folderId) {
this.groupingsComponent.selectedFolder = true;
this.groupingsComponent.selectedFolderId = params.folderId;
await this.filterFolder(params.folderId);
} else if (params.collectionId) {
this.groupingsComponent.selectedCollectionId = params.collectionId;
await this.filterCollection(params.collectionId);
} else {
this.groupingsComponent.selectedAll = true;
await this.ciphersComponent.load();
}
this.route.queryParams.subscribe(async (params) => {
await this.load(params);
});
}
async load(params?: { [key: string]: any }) {
if (params == null) {
this.groupingsComponent.selectedAll = true;
await this.groupingsComponent.load();
await this.ciphersComponent.load();
return;
}
if (params.cipherId) {
const cipherView = new CipherView();
cipherView.id = params.cipherId;
if (params.action === 'edit') {
this.editCipher(cipherView);
} else {
this.viewCipher(cipherView);
}
} else if (params.action === 'add') {
this.addCipher();
}
if (params.favorites) {
this.groupingsComponent.selectedFavorites = true;
await this.filterFavorites();
} else if (params.type) {
const t = parseInt(params.type, null);
this.groupingsComponent.selectedType = t;
await this.filterCipherType(t);
} else if (params.folderId) {
this.groupingsComponent.selectedFolder = true;
this.groupingsComponent.selectedFolderId = params.folderId;
await this.filterFolder(params.folderId);
} else if (params.collectionId) {
this.groupingsComponent.selectedCollectionId = params.collectionId;
await this.filterCollection(params.collectionId);
} else {
this.groupingsComponent.selectedAll = true;
await this.groupingsComponent.load();
await this.ciphersComponent.load();
}
}
viewCipher(cipher: CipherView) {
if (this.action === 'view' && this.cipherId === cipher.id) {
return;