Browse Source

redundant transfer state usages removed

pull/23416/head
erdemcaygor 1 year ago
parent
commit
810459a843
  1. 28
      npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts
  2. 24
      npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts
  3. 25
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

28
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<any>('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);
}
});
}
});
}
}

24
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<any>('roles');
data: PagedResultDto<IdentityRoleDto> = { 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<PagedResultDto<IdentityRoleDto>>(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) {

25
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<any>('users');
data: PagedResultDto<IdentityUserDto> = { items: [], totalCount: 0 };
@ -125,9 +122,7 @@ export class UsersComponent implements OnInit {
trackByFn: TrackByFunction<AbstractControl> = (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) {

Loading…
Cancel
Save