From 810459a8434bac2de87858ab646175ee07f6c8de Mon Sep 17 00:00:00 2001 From: erdemcaygor Date: Tue, 12 Aug 2025 14:54:59 +0300 Subject: [PATCH] redundant transfer state usages removed --- .../manage-profile.component.ts | 28 ++++--------------- .../lib/components/roles/roles.component.ts | 24 ++++------------ .../lib/components/users/users.component.ts | 25 ++++------------- 3 files changed, 18 insertions(+), 59 deletions(-) diff --git a/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts b/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts index ec3393c486..9de24c6c88 100644 --- a/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts @@ -1,12 +1,12 @@ import { ProfileService } from '@abp/ng.account.core/proxy'; import { fadeIn, LoadingDirective } from '@abp/ng.theme.shared'; import { transition, trigger, useAnimation } from '@angular/animations'; -import { Component, inject, makeStateKey, OnInit, TransferState } from '@angular/core'; +import { Component, inject, OnInit } from '@angular/core'; import { eAccountComponents } from '../../enums/components'; import { ManageProfileStateService } from '../../services/manage-profile.state.service'; import { NgClass, AsyncPipe } from '@angular/common'; import { ReactiveFormsModule } from '@angular/forms'; -import { LocalizationPipe, ReplaceableTemplateDirective, SSRService } from '@abp/ng.core'; +import { LocalizationPipe, ReplaceableTemplateDirective } from '@abp/ng.core'; import { PersonalSettingsComponent } from '../personal-settings/personal-settings.component'; import { ChangePasswordComponent } from '../change-password/change-password.component'; @@ -37,7 +37,6 @@ export class ManageProfileComponent implements OnInit { protected profileService = inject(ProfileService); protected manageProfileState = inject(ManageProfileStateService); - protected readonly ssrService = inject(SSRService); selectedTab = 0; changePasswordKey = eAccountComponents.ChangePassword; @@ -47,32 +46,17 @@ export class ManageProfileComponent implements OnInit { profile$ = this.manageProfileState.getProfile$(); hideChangePasswordTab?: boolean; - PROFILE_SETTINGS_KEY = makeStateKey('profileSettings'); constructor( - private transferState: TransferState ) {} ngOnInit() { - if (this.transferState.hasKey(this.PROFILE_SETTINGS_KEY)) { - const profileSettings = this.transferState.get(this.PROFILE_SETTINGS_KEY, null); - this.manageProfileState.setProfile(profileSettings); - if (profileSettings.isExternal) { + this.profileService.get().subscribe(profile => { + this.manageProfileState.setProfile(profile); + if (profile.isExternal) { this.hideChangePasswordTab = true; this.selectedTab = 1; } - this.transferState.remove(this.PROFILE_SETTINGS_KEY); - } else { - this.profileService.get().subscribe(profile => { - this.manageProfileState.setProfile(profile); - if (profile.isExternal) { - this.hideChangePasswordTab = true; - this.selectedTab = 1; - } - if (this.ssrService.isServer) { - this.transferState.set(this.PROFILE_SETTINGS_KEY, profile); - } - }); - } + }); } } diff --git a/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts b/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts index c577b3fd33..8c87f933a8 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts +++ b/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts @@ -27,7 +27,7 @@ import { FormPropData, generateFormFromProps, } from '@abp/ng.components/extensible'; -import { Component, inject, Injector, makeStateKey, OnInit, TransferState } from '@angular/core'; +import { Component, inject, Injector, OnInit } from '@angular/core'; import { ReactiveFormsModule, UntypedFormGroup } from '@angular/forms'; import { finalize } from 'rxjs/operators'; import { eIdentityComponents } from '../../enums/components'; @@ -67,7 +67,6 @@ export class RolesComponent implements OnInit { protected readonly service = inject(IdentityRoleService); protected readonly ssrService = inject(SSRService); - ROLES_KEY = makeStateKey('roles'); data: PagedResultDto = { items: [], totalCount: 0 }; form!: UntypedFormGroup; selected?: IdentityRoleDto; @@ -77,7 +76,7 @@ export class RolesComponent implements OnInit { modalBusy = false; permissionManagementKey = ePermissionManagementComponents.PermissionManagement; - constructor(private transferState: TransferState) {} + constructor() {} onVisiblePermissionChange = (event: boolean) => { this.visiblePermissions = event; @@ -140,22 +139,11 @@ export class RolesComponent implements OnInit { } private hookToQuery() { - if (this.transferState.hasKey(this.ROLES_KEY)) { - this.data = this.transferState.get>(this.ROLES_KEY, { - items: [], - totalCount: 0, + this.list + .hookToQuery(query => this.service.getList(query)) + .subscribe(res => { + this.data = res; }); - this.transferState.remove(this.ROLES_KEY); - } else { - this.list - .hookToQuery(query => this.service.getList(query)) - .subscribe(res => { - this.data = res; - if (this.ssrService.isServer) { - this.transferState.set(this.ROLES_KEY, res); - } - }); - } } openPermissionsModal(providerKey: string) { diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts index 727f216ed3..9248e44e40 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts @@ -4,7 +4,6 @@ import { LocalizationPipe, PagedResultDto, ReplaceableTemplateDirective, - SSRService, } from '@abp/ng.core'; import { GetIdentityUsersInput, @@ -37,7 +36,6 @@ import { Component, inject, Injector, - makeStateKey, OnInit, TemplateRef, TrackByFunction, @@ -94,7 +92,6 @@ export class UsersComponent implements OnInit { protected readonly toasterService = inject(ToasterService); private readonly fb = inject(UntypedFormBuilder); private readonly injector = inject(Injector); - USERS_KEY = makeStateKey('users'); data: PagedResultDto = { items: [], totalCount: 0 }; @@ -125,9 +122,7 @@ export class UsersComponent implements OnInit { trackByFn: TrackByFunction = (index, item) => Object.keys(item)[0] || index; - public ssrService = inject(SSRService); - - constructor(private transferState: TransferState) {} + constructor() {} onVisiblePermissionChange = (event: boolean) => { this.visiblePermissions = event; @@ -240,19 +235,11 @@ export class UsersComponent implements OnInit { } private hookToQuery() { - if (this.transferState.hasKey(this.USERS_KEY)) { - this.data = this.transferState.get(this.USERS_KEY, { items: [], totalCount: 0 }); - this.transferState.remove(this.USERS_KEY); - } else { - this.list - .hookToQuery(query => this.service.getList(query)) - .subscribe(res => { - this.data = res; - if (this.ssrService.isServer) { - this.transferState.set(this.USERS_KEY, res); - } - }); - } + this.list + .hookToQuery(query => this.service.getList(query)) + .subscribe(res => { + this.data = res; + }); } openPermissionsModal(providerKey: string, entityDisplayName?: string) {