From 6b4bb33e1707552cf8079b4a9430041d041e7b4d Mon Sep 17 00:00:00 2001 From: Bastian Rihm Date: Fri, 26 Jul 2024 15:45:02 +0200 Subject: [PATCH 1/2] Fix account list performance --- .../account-main/account-main.component.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts b/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts index 1bce1f15a6..eabba6390b 100644 --- a/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core'; import { inject } from '@angular/core'; -import { distinctUntilChanged, map } from 'rxjs'; +import { distinctUntilChanged, map, skip, startWith } from 'rxjs'; import { OML } from 'src/app/domain/definitions/organization-permission'; import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; import { ViewUser } from 'src/app/site/pages/meetings/view-models/view-user'; @@ -35,24 +35,23 @@ const accountListSubsciptionContent = { styleUrls: [`./account-main.component.scss`] }) export class AccountMainComponent extends BaseModelRequestHandlerComponent { - protected operator: OperatorService; + protected operator: OperatorService = inject(OperatorService); - public constructor() { - super(); - - this.operator = inject(OperatorService); + protected override async onBeforeModelRequests(): Promise { + await this.operator.ready; } protected override async onShouldCreateModelRequests(): Promise { - await this.operator.ready; this.subscribeTo( this.getAccountSubscriptionForCurrentPerm(this.operator.hasOrganizationPermissions(OML.can_manage_users)), { hideWhenMeetingChanged: true } ); + this.operator.userObservable .pipe( map(user => user && !!user?.organization_management_level), - distinctUntilChanged() + distinctUntilChanged(), + skip(1) ) .subscribe(hasOrgaRights => { this.updateSubscribeTo(this.getAccountSubscriptionForCurrentPerm(hasOrgaRights), { From f380eb2213cb1f2f62d26d54486ceb884ae4abf8 Mon Sep 17 00:00:00 2001 From: Bastian Rihm Date: Fri, 26 Jul 2024 15:48:38 +0200 Subject: [PATCH 2/2] Fix rxjs subscription not closed --- .../account-main/account-main.component.ts | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts b/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts index eabba6390b..b173d852e4 100644 --- a/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core'; import { inject } from '@angular/core'; -import { distinctUntilChanged, map, skip, startWith } from 'rxjs'; +import { distinctUntilChanged, map, skip } from 'rxjs'; import { OML } from 'src/app/domain/definitions/organization-permission'; import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; import { ViewUser } from 'src/app/site/pages/meetings/view-models/view-user'; @@ -47,17 +47,19 @@ export class AccountMainComponent extends BaseModelRequestHandlerComponent { { hideWhenMeetingChanged: true } ); - this.operator.userObservable - .pipe( - map(user => user && !!user?.organization_management_level), - distinctUntilChanged(), - skip(1) - ) - .subscribe(hasOrgaRights => { - this.updateSubscribeTo(this.getAccountSubscriptionForCurrentPerm(hasOrgaRights), { - hideWhenMeetingChanged: true - }); - }); + this.subscriptions.push( + this.operator.userObservable + .pipe( + map(user => user && !!user?.organization_management_level), + distinctUntilChanged(), + skip(1) + ) + .subscribe(hasOrgaRights => { + this.updateSubscribeTo(this.getAccountSubscriptionForCurrentPerm(hasOrgaRights), { + hideWhenMeetingChanged: true + }); + }) + ); } private getAccountSubscriptionForCurrentPerm(isUserAdmin: boolean): any {