1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-15 02:18:42 +02:00

unsubscribe from queryparams observable

This commit is contained in:
Kyle Spearrin 2018-12-20 10:06:40 -05:00
parent 7efd81191a
commit 5804c57236
8 changed files with 36 additions and 27 deletions

View File

@ -26,7 +26,7 @@ export class LoginComponent extends BaseLoginComponent {
} }
async ngOnInit() { async ngOnInit() {
this.route.queryParams.subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => {
if (qParams.email != null && qParams.email.indexOf('@') > -1) { if (qParams.email != null && qParams.email.indexOf('@') > -1) {
this.email = qParams.email; this.email = qParams.email;
} }
@ -37,6 +37,7 @@ export class LoginComponent extends BaseLoginComponent {
{ route: '/settings/create-organization', qParams: { plan: qParams.org } }); { route: '/settings/create-organization', qParams: { plan: qParams.org } });
} }
await super.ngOnInit(); await super.ngOnInit();
queryParamsSub.unsubscribe();
}); });
} }

View File

@ -33,7 +33,7 @@ export class RegisterComponent extends BaseRegisterComponent {
} }
ngOnInit() { ngOnInit() {
this.route.queryParams.subscribe((qParams) => { const queryParamsSub = this.route.queryParams.subscribe((qParams) => {
if (qParams.email != null && qParams.email.indexOf('@') > -1) { if (qParams.email != null && qParams.email.indexOf('@') > -1) {
this.email = qParams.email; this.email = qParams.email;
} }
@ -44,6 +44,7 @@ export class RegisterComponent extends BaseRegisterComponent {
this.stateService.save('loginRedirect', this.stateService.save('loginRedirect',
{ route: '/settings/create-organization', qParams: { plan: qParams.org } }); { route: '/settings/create-organization', qParams: { plan: qParams.org } });
} }
queryParamsSub.unsubscribe();
}); });
} }
} }

View File

@ -54,8 +54,9 @@ export class CollectionsComponent implements OnInit {
this.route.parent.parent.params.subscribe(async (params) => { this.route.parent.parent.params.subscribe(async (params) => {
this.organizationId = params.organizationId; this.organizationId = params.organizationId;
await this.load(); await this.load();
this.route.queryParams.subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => {
this.searchText = qParams.search; this.searchText = qParams.search;
queryParamsSub.unsubscribe();
}); });
}); });
} }

View File

@ -56,8 +56,9 @@ export class GroupsComponent implements OnInit {
return; return;
} }
await this.load(); await this.load();
this.route.queryParams.subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => {
this.searchText = qParams.search; this.searchText = qParams.search;
queryParamsSub.unsubscribe();
}); });
}); });
} }

View File

@ -81,7 +81,7 @@ export class PeopleComponent implements OnInit {
this.accessGroups = organization.useGroups; this.accessGroups = organization.useGroups;
await this.load(); await this.load();
this.route.queryParams.subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => {
this.searchText = qParams.search; this.searchText = qParams.search;
if (qParams.viewEvents != null) { if (qParams.viewEvents != null) {
const user = this.users.filter((u) => u.id === qParams.viewEvents); const user = this.users.filter((u) => u.id === qParams.viewEvents);
@ -89,6 +89,7 @@ export class PeopleComponent implements OnInit {
this.events(user[0]); this.events(user[0]);
} }
} }
queryParamsSub.unsubscribe();
}); });
}); });
} }

View File

@ -66,7 +66,7 @@ export class VaultComponent implements OnInit, OnDestroy {
this.groupingsComponent.organization = this.organization; this.groupingsComponent.organization = this.organization;
this.ciphersComponent.organization = this.organization; this.ciphersComponent.organization = this.organization;
this.route.queryParams.subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => {
this.ciphersComponent.searchText = this.groupingsComponent.searchText = qParams.search; this.ciphersComponent.searchText = this.groupingsComponent.searchText = qParams.search;
if (!this.organization.isAdmin) { if (!this.organization.isAdmin) {
await this.syncService.fullSync(false); await this.syncService.fullSync(false);
@ -111,6 +111,8 @@ export class VaultComponent implements OnInit, OnDestroy {
this.viewEvents(cipher[0]); this.viewEvents(cipher[0]);
} }
} }
queryParamsSub.unsubscribe();
}); });
}); });
} }

View File

@ -92,10 +92,11 @@ export class CreateOrganizationComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.route.queryParams.subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => {
if (qParams.plan === 'families' || qParams.plan === 'teams' || qParams.plan === 'enterprise') { if (qParams.plan === 'families' || qParams.plan === 'teams' || qParams.plan === 'enterprise') {
this.plan = qParams.plan; this.plan = qParams.plan;
} }
queryParamsSub.unsubscribe();
}); });
} }

View File

@ -87,7 +87,7 @@ export class VaultComponent implements OnInit, OnDestroy {
this.showVerifyEmail = !(await this.tokenService.getEmailVerified()); this.showVerifyEmail = !(await this.tokenService.getEmailVerified());
this.showBrowserOutdated = window.navigator.userAgent.indexOf('MSIE') !== -1; this.showBrowserOutdated = window.navigator.userAgent.indexOf('MSIE') !== -1;
this.route.queryParams.subscribe(async (params) => { const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
await this.syncService.fullSync(false); await this.syncService.fullSync(false);
this.showUpdateKey = !(await this.cryptoService.hasEncKey()); this.showUpdateKey = !(await this.cryptoService.hasEncKey());
@ -103,26 +103,25 @@ export class VaultComponent implements OnInit, OnDestroy {
if (params == null) { if (params == null) {
this.groupingsComponent.selectedAll = true; this.groupingsComponent.selectedAll = true;
await this.ciphersComponent.load(); await this.ciphersComponent.load();
return;
}
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 { } else {
this.groupingsComponent.selectedAll = true; if (params.favorites) {
await this.ciphersComponent.load(); 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.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => { this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
@ -141,6 +140,8 @@ export class VaultComponent implements OnInit, OnDestroy {
} }
}); });
}); });
queryParamsSub.unsubscribe();
}); });
} }