diff --git a/apps/client/src/app/app.component.ts b/apps/client/src/app/app.component.ts index 738d62a92..ce94cbc7b 100644 --- a/apps/client/src/app/app.component.ts +++ b/apps/client/src/app/app.component.ts @@ -73,16 +73,19 @@ export class AppComponent implements OnDestroy, OnInit { this.isLoggedIn = !!this.tokenStorageService.getToken(); if (this.isLoggedIn) { - this.userService.get().subscribe((user) => { - this.user = user; - - this.canCreateAccount = hasPermission( - this.user.permissions, - permissions.createUserAccount - ); - - this.cd.markForCheck(); - }); + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; + + this.canCreateAccount = hasPermission( + this.user.permissions, + permissions.createUserAccount + ); + + this.cd.markForCheck(); + }); } else { this.user = null; } diff --git a/apps/client/src/app/pages/about/about-page.component.ts b/apps/client/src/app/pages/about/about-page.component.ts index 28ec58a9f..ac5d50d29 100644 --- a/apps/client/src/app/pages/about/about-page.component.ts +++ b/apps/client/src/app/pages/about/about-page.component.ts @@ -44,11 +44,14 @@ export class AboutPageComponent implements OnInit { .onChangeHasToken() .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { - this.userService.get().subscribe((user) => { - this.user = user; - - this.cd.markForCheck(); - }); + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; + + this.cd.markForCheck(); + }); }); } diff --git a/apps/client/src/app/pages/account/account-page.component.ts b/apps/client/src/app/pages/account/account-page.component.ts index be049bddf..9f4535e22 100644 --- a/apps/client/src/app/pages/account/account-page.component.ts +++ b/apps/client/src/app/pages/account/account-page.component.ts @@ -50,16 +50,19 @@ export class AccountPageComponent implements OnDestroy, OnInit { .onChangeHasToken() .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { - this.userService.get().subscribe((user) => { - this.user = user; + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; - this.hasPermissionToUpdateUserSettings = hasPermission( - this.user.permissions, - permissions.updateUserSettings - ); + this.hasPermissionToUpdateUserSettings = hasPermission( + this.user.permissions, + permissions.updateUserSettings + ); - this.cd.markForCheck(); - }); + this.cd.markForCheck(); + }); }); } @@ -82,11 +85,14 @@ export class AccountPageComponent implements OnDestroy, OnInit { .subscribe(() => { this.userService.remove(); - this.userService.get().subscribe((user) => { - this.user = user; + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; - this.cd.markForCheck(); - }); + this.cd.markForCheck(); + }); }); } diff --git a/apps/client/src/app/pages/accounts/accounts-page.component.ts b/apps/client/src/app/pages/accounts/accounts-page.component.ts index d6fb22bbc..cf631bc39 100644 --- a/apps/client/src/app/pages/accounts/accounts-page.component.ts +++ b/apps/client/src/app/pages/accounts/accounts-page.component.ts @@ -81,20 +81,23 @@ export class AccountsPageComponent implements OnInit { .onChangeHasToken() .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { - this.userService.get().subscribe((user) => { - this.user = user; - - this.hasPermissionToCreateAccount = hasPermission( - user.permissions, - permissions.createAccount - ); - this.hasPermissionToDeleteAccount = hasPermission( - user.permissions, - permissions.deleteAccount - ); - - this.cd.markForCheck(); - }); + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; + + this.hasPermissionToCreateAccount = hasPermission( + user.permissions, + permissions.createAccount + ); + this.hasPermissionToDeleteAccount = hasPermission( + user.permissions, + permissions.deleteAccount + ); + + this.cd.markForCheck(); + }); }); this.fetchAccounts(); diff --git a/apps/client/src/app/pages/admin/admin-page.component.ts b/apps/client/src/app/pages/admin/admin-page.component.ts index e69cb4d9d..1b25c50fc 100644 --- a/apps/client/src/app/pages/admin/admin-page.component.ts +++ b/apps/client/src/app/pages/admin/admin-page.component.ts @@ -49,9 +49,12 @@ export class AdminPageComponent implements OnInit { .onChangeHasToken() .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { - this.userService.get().subscribe((user) => { - this.user = user; - }); + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; + }); }); } diff --git a/apps/client/src/app/pages/analysis/analysis-page.component.ts b/apps/client/src/app/pages/analysis/analysis-page.component.ts index addb38884..2fffa14a7 100644 --- a/apps/client/src/app/pages/analysis/analysis-page.component.ts +++ b/apps/client/src/app/pages/analysis/analysis-page.component.ts @@ -85,11 +85,14 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { .onChangeHasToken() .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { - this.userService.get().subscribe((user) => { - this.user = user; - - this.cd.markForCheck(); - }); + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; + + this.cd.markForCheck(); + }); }); } diff --git a/apps/client/src/app/pages/home/home-page.component.ts b/apps/client/src/app/pages/home/home-page.component.ts index 1fe0f8236..faec629f4 100644 --- a/apps/client/src/app/pages/home/home-page.component.ts +++ b/apps/client/src/app/pages/home/home-page.component.ts @@ -82,32 +82,35 @@ export class HomePageComponent implements OnDestroy, OnInit { .onChangeHasToken() .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { - this.userService.get().subscribe((user) => { - this.user = user; - - this.hasPermissionToAccessFearAndGreedIndex = hasPermission( - user.permissions, - permissions.accessFearAndGreedIndex - ); - - if (this.hasPermissionToAccessFearAndGreedIndex) { - this.dataService - .fetchSymbolItem('GF.FEAR_AND_GREED_INDEX') - .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ marketPrice }) => { - this.fearAndGreedIndex = marketPrice; - - this.cd.markForCheck(); - }); - } - - this.hasPermissionToReadForeignPortfolio = hasPermission( - user.permissions, - permissions.readForeignPortfolio - ); - - this.cd.markForCheck(); - }); + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; + + this.hasPermissionToAccessFearAndGreedIndex = hasPermission( + user.permissions, + permissions.accessFearAndGreedIndex + ); + + if (this.hasPermissionToAccessFearAndGreedIndex) { + this.dataService + .fetchSymbolItem('GF.FEAR_AND_GREED_INDEX') + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(({ marketPrice }) => { + this.fearAndGreedIndex = marketPrice; + + this.cd.markForCheck(); + }); + } + + this.hasPermissionToReadForeignPortfolio = hasPermission( + user.permissions, + permissions.readForeignPortfolio + ); + + this.cd.markForCheck(); + }); }); } diff --git a/apps/client/src/app/pages/pricing/pricing-page.component.ts b/apps/client/src/app/pages/pricing/pricing-page.component.ts index e6d0ab5a2..135d30249 100644 --- a/apps/client/src/app/pages/pricing/pricing-page.component.ts +++ b/apps/client/src/app/pages/pricing/pricing-page.component.ts @@ -40,11 +40,14 @@ export class PricingPageComponent implements OnInit { .onChangeHasToken() .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { - this.userService.get().subscribe((user) => { - this.user = user; + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; - this.cd.markForCheck(); - }); + this.cd.markForCheck(); + }); }); } diff --git a/apps/client/src/app/pages/transactions/transactions-page.component.ts b/apps/client/src/app/pages/transactions/transactions-page.component.ts index d1381417e..f1e3a3951 100644 --- a/apps/client/src/app/pages/transactions/transactions-page.component.ts +++ b/apps/client/src/app/pages/transactions/transactions-page.component.ts @@ -81,20 +81,23 @@ export class TransactionsPageComponent implements OnInit { .onChangeHasToken() .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { - this.userService.get().subscribe((user) => { - this.user = user; - - this.hasPermissionToCreateOrder = hasPermission( - user.permissions, - permissions.createOrder - ); - this.hasPermissionToDeleteOrder = hasPermission( - user.permissions, - permissions.deleteOrder - ); - - this.cd.markForCheck(); - }); + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; + + this.hasPermissionToCreateOrder = hasPermission( + user.permissions, + permissions.createOrder + ); + this.hasPermissionToDeleteOrder = hasPermission( + user.permissions, + permissions.deleteOrder + ); + + this.cd.markForCheck(); + }); }); this.fetchOrders(); diff --git a/apps/client/src/app/pages/zen/zen-page.component.ts b/apps/client/src/app/pages/zen/zen-page.component.ts index f30102117..6781e9ad0 100644 --- a/apps/client/src/app/pages/zen/zen-page.component.ts +++ b/apps/client/src/app/pages/zen/zen-page.component.ts @@ -43,16 +43,19 @@ export class ZenPageComponent implements OnDestroy, OnInit { .onChangeHasToken() .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { - this.userService.get().subscribe((user) => { - this.user = user; + this.userService + .get() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((user) => { + this.user = user; - this.hasPermissionToReadForeignPortfolio = hasPermission( - user.permissions, - permissions.readForeignPortfolio - ); + this.hasPermissionToReadForeignPortfolio = hasPermission( + user.permissions, + permissions.readForeignPortfolio + ); - this.cd.markForCheck(); - }); + this.cd.markForCheck(); + }); }); }