From 5804c5723684a5c31713af6a0db2b0c2c18466e0 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 20 Dec 2018 10:06:40 -0500 Subject: [PATCH] unsubscribe from queryparams observable --- src/app/accounts/login.component.ts | 3 +- src/app/accounts/register.component.ts | 3 +- .../manage/collections.component.ts | 3 +- .../organizations/manage/groups.component.ts | 3 +- .../organizations/manage/people.component.ts | 3 +- .../organizations/vault/vault.component.ts | 4 +- .../settings/create-organization.component.ts | 3 +- src/app/vault/vault.component.ts | 41 ++++++++++--------- 8 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/app/accounts/login.component.ts b/src/app/accounts/login.component.ts index 6a392c9315..bf7f5893d7 100644 --- a/src/app/accounts/login.component.ts +++ b/src/app/accounts/login.component.ts @@ -26,7 +26,7 @@ export class LoginComponent extends BaseLoginComponent { } async ngOnInit() { - this.route.queryParams.subscribe(async (qParams) => { + const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => { if (qParams.email != null && qParams.email.indexOf('@') > -1) { this.email = qParams.email; } @@ -37,6 +37,7 @@ export class LoginComponent extends BaseLoginComponent { { route: '/settings/create-organization', qParams: { plan: qParams.org } }); } await super.ngOnInit(); + queryParamsSub.unsubscribe(); }); } diff --git a/src/app/accounts/register.component.ts b/src/app/accounts/register.component.ts index 8afadf538d..ca97fc20d1 100644 --- a/src/app/accounts/register.component.ts +++ b/src/app/accounts/register.component.ts @@ -33,7 +33,7 @@ export class RegisterComponent extends BaseRegisterComponent { } ngOnInit() { - this.route.queryParams.subscribe((qParams) => { + const queryParamsSub = this.route.queryParams.subscribe((qParams) => { if (qParams.email != null && qParams.email.indexOf('@') > -1) { this.email = qParams.email; } @@ -44,6 +44,7 @@ export class RegisterComponent extends BaseRegisterComponent { this.stateService.save('loginRedirect', { route: '/settings/create-organization', qParams: { plan: qParams.org } }); } + queryParamsSub.unsubscribe(); }); } } diff --git a/src/app/organizations/manage/collections.component.ts b/src/app/organizations/manage/collections.component.ts index 067bdbd716..f7304d1796 100644 --- a/src/app/organizations/manage/collections.component.ts +++ b/src/app/organizations/manage/collections.component.ts @@ -54,8 +54,9 @@ export class CollectionsComponent implements OnInit { this.route.parent.parent.params.subscribe(async (params) => { this.organizationId = params.organizationId; await this.load(); - this.route.queryParams.subscribe(async (qParams) => { + const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => { this.searchText = qParams.search; + queryParamsSub.unsubscribe(); }); }); } diff --git a/src/app/organizations/manage/groups.component.ts b/src/app/organizations/manage/groups.component.ts index 75c113675c..62e058f286 100644 --- a/src/app/organizations/manage/groups.component.ts +++ b/src/app/organizations/manage/groups.component.ts @@ -56,8 +56,9 @@ export class GroupsComponent implements OnInit { return; } await this.load(); - this.route.queryParams.subscribe(async (qParams) => { + const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => { this.searchText = qParams.search; + queryParamsSub.unsubscribe(); }); }); } diff --git a/src/app/organizations/manage/people.component.ts b/src/app/organizations/manage/people.component.ts index e0b9d57825..83f3ec4150 100644 --- a/src/app/organizations/manage/people.component.ts +++ b/src/app/organizations/manage/people.component.ts @@ -81,7 +81,7 @@ export class PeopleComponent implements OnInit { this.accessGroups = organization.useGroups; await this.load(); - this.route.queryParams.subscribe(async (qParams) => { + const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => { this.searchText = qParams.search; if (qParams.viewEvents != null) { const user = this.users.filter((u) => u.id === qParams.viewEvents); @@ -89,6 +89,7 @@ export class PeopleComponent implements OnInit { this.events(user[0]); } } + queryParamsSub.unsubscribe(); }); }); } diff --git a/src/app/organizations/vault/vault.component.ts b/src/app/organizations/vault/vault.component.ts index 19a0abc97c..0a543966fb 100644 --- a/src/app/organizations/vault/vault.component.ts +++ b/src/app/organizations/vault/vault.component.ts @@ -66,7 +66,7 @@ export class VaultComponent implements OnInit, OnDestroy { this.groupingsComponent.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; if (!this.organization.isAdmin) { await this.syncService.fullSync(false); @@ -111,6 +111,8 @@ export class VaultComponent implements OnInit, OnDestroy { this.viewEvents(cipher[0]); } } + + queryParamsSub.unsubscribe(); }); }); } diff --git a/src/app/settings/create-organization.component.ts b/src/app/settings/create-organization.component.ts index 88cdd71818..5f7f486cb6 100644 --- a/src/app/settings/create-organization.component.ts +++ b/src/app/settings/create-organization.component.ts @@ -92,10 +92,11 @@ export class CreateOrganizationComponent implements OnInit { } 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') { this.plan = qParams.plan; } + queryParamsSub.unsubscribe(); }); } diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index a9243c275b..936702e9c4 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -87,7 +87,7 @@ export class VaultComponent implements OnInit, OnDestroy { this.showVerifyEmail = !(await this.tokenService.getEmailVerified()); 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); this.showUpdateKey = !(await this.cryptoService.hasEncKey()); @@ -103,26 +103,25 @@ export class VaultComponent implements OnInit, OnDestroy { if (params == null) { this.groupingsComponent.selectedAll = true; 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 { - this.groupingsComponent.selectedAll = true; - await this.ciphersComponent.load(); + 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.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => { @@ -141,6 +140,8 @@ export class VaultComponent implements OnInit, OnDestroy { } }); }); + + queryParamsSub.unsubscribe(); }); }