diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a8aa975c48..41b76cbe69 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -61,9 +61,6 @@ export class AppComponent implements OnInit { case 'logout': this.logOut(message.expired); break; - case 'doneLoggingOut': - this.doneLoggingOut(message.expired); - break; case 'locked': break; case 'unlocked': @@ -92,10 +89,6 @@ export class AppComponent implements OnInit { this.passwordGenerationService.clear(), ]); - this.doneLoggingOut(expired); - } - - private doneLoggingOut(expired: boolean) { this.authService.logOut(() => { this.analytics.eventTrack.next({ action: 'Logged Out' }); if (expired) { diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index 84b63c21ae..201110e077 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -15,6 +15,9 @@ import { Router, } from '@angular/router'; +import { ToasterService } from 'angular2-toaster'; +import { Angulartics2 } from 'angulartics2'; + import { ModalComponent } from '../modal.component'; import { BroadcasterService } from '../services/broadcaster.service'; @@ -60,7 +63,8 @@ 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 syncService: SyncService) { + private ngZone: NgZone, private syncService: SyncService, private analytics: Angulartics2, + private toasterService: ToasterService) { } async ngOnInit() { @@ -91,6 +95,18 @@ export class VaultComponent implements OnInit { case 'openPasswordGenerator': await this.openPasswordGenerator(false); break; + case 'syncVault': + try { + await this.syncService.fullSync(true); + this.toasterService.popAsync('success', null, this.i18nService.t('syncingComplete')); + this.analytics.eventTrack.next({ action: 'Synced Full' }); + } catch { + this.toasterService.popAsync('error', null, this.i18nService.t('syncingFailed')); + } + break; + case 'syncCompleted': + await this.load(); + break; default: detectChanges = false; break; @@ -102,54 +118,52 @@ export class VaultComponent implements OnInit { }); }); - while (this.syncService.syncInProgress) { - await new Promise((resolve) => setTimeout(resolve, 200)); + if (!this.syncService.syncInProgress) { + await this.load(); } - - this.route.queryParams.subscribe(async (params) => { - await this.load(params); - }); } - async load(params?: { [key: string]: any }) { - await this.groupingsComponent.load(); + async load() { + this.route.queryParams.subscribe(async (params) => { + await this.groupingsComponent.load(); - if (params == null) { - this.groupingsComponent.selectedAll = true; - 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); + if (params == null) { + this.groupingsComponent.selectedAll = true; + await this.ciphersComponent.load(); + return; } - } 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.ciphersComponent.load(); - } + 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.ciphersComponent.load(); + } + }); } viewCipher(cipher: CipherView) { diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 63305301ba..934417b034 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -664,13 +664,19 @@ "changeEmailConfirmation": { "message": "You can change your email address on the bitwarden.com web vault. Do you want to visit the website now?" }, - "webVault": { - "message": "Web Vault" + "goToWebVault": { + "message": "Go To Web Vault" }, "getMobileApp": { "message": "Get Mobile App" }, "getBrowserExtension": { "message": "Get Browser Extension" + }, + "syncingComplete": { + "message": "Syncing complete" + }, + "syncingFailed": { + "message": "Syncing failed" } } diff --git a/src/main/menu.main.ts b/src/main/menu.main.ts index 149488ff5a..37b793b30c 100644 --- a/src/main/menu.main.ts +++ b/src/main/menu.main.ts @@ -259,7 +259,7 @@ export class MenuMain { }, { type: 'separator' }, { - label: this.i18nService.t('webVault'), + label: this.i18nService.t('goToWebVault'), click() { shell.openExternal('https://vault.bitwarden.com'); }