Browse Source

redundant transfer state usages removed

pull/23416/head
erdemcaygor 1 year ago
parent
commit
142e9e1283
  1. 1
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts
  2. 26
      npm/ng-packs/packages/setting-management/config/src/lib/components/email-setting-group/email-setting-group.component.ts
  3. 24
      npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts

1
npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

@ -39,7 +39,6 @@ import {
OnInit, OnInit,
TemplateRef, TemplateRef,
TrackByFunction, TrackByFunction,
TransferState,
ViewChild, ViewChild,
} from '@angular/core'; } from '@angular/core';
import { import {

26
npm/ng-packs/packages/setting-management/config/src/lib/components/email-setting-group/email-setting-group.component.ts

@ -6,7 +6,7 @@ import {
ModalComponent, ModalComponent,
ToasterService, ToasterService,
} from '@abp/ng.theme.shared'; } from '@abp/ng.theme.shared';
import { Component, inject, makeStateKey, OnInit, TransferState } from '@angular/core'; import { Component, inject, OnInit } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop'; import { toSignal } from '@angular/core/rxjs-interop';
import { import {
ReactiveFormsModule, ReactiveFormsModule,
@ -22,8 +22,7 @@ import {
ConfigStateService, ConfigStateService,
LocalizationPipe, LocalizationPipe,
LocalizationService, LocalizationService,
PermissionDirective, PermissionDirective
SSRService,
} from '@abp/ng.core'; } from '@abp/ng.core';
import { NgxValidateCoreModule } from '@ngx-validate/core'; import { NgxValidateCoreModule } from '@ngx-validate/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
@ -52,7 +51,6 @@ export class EmailSettingGroupComponent implements OnInit {
protected readonly localizationService = inject(LocalizationService); protected readonly localizationService = inject(LocalizationService);
protected readonly configStateSevice = inject(ConfigStateService); protected readonly configStateSevice = inject(ConfigStateService);
protected readonly ssrService = inject(SSRService);
protected readonly currentUserEmail = toSignal( protected readonly currentUserEmail = toSignal(
this.configStateSevice.getDeep$(['currentUser', 'email']), this.configStateSevice.getDeep$(['currentUser', 'email']),
); );
@ -63,29 +61,17 @@ export class EmailSettingGroupComponent implements OnInit {
emailingPolicy = SettingManagementPolicyNames.Emailing; emailingPolicy = SettingManagementPolicyNames.Emailing;
isEmailTestModalOpen = false; isEmailTestModalOpen = false;
modalSize: NgbModalOptions = { size: 'lg' }; modalSize: NgbModalOptions = { size: 'lg' };
EMAIL_SETTINGS_KEY = makeStateKey<any>('emailSettings');
constructor( constructor() {}
private transferState: TransferState,
) {}
ngOnInit() { ngOnInit() {
this.getData(); this.getData();
} }
private getData() { private getData() {
if (this.transferState.hasKey(this.EMAIL_SETTINGS_KEY)) { this.emailSettingsService.get().subscribe(res => {
const emailSettings = this.transferState.get<EmailSettingsDto>(this.EMAIL_SETTINGS_KEY, null); this.buildForm(res);
this.buildForm(emailSettings); });
this.transferState.remove(this.EMAIL_SETTINGS_KEY);
} else {
this.emailSettingsService.get().subscribe(res => {
this.buildForm(res);
if (this.ssrService.isServer) {
this.transferState.set(this.EMAIL_SETTINGS_KEY, res);
}
});
}
} }
private buildForm(emailSettings: EmailSettingsDto) { private buildForm(emailSettings: EmailSettingsDto) {

24
npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts

@ -3,7 +3,6 @@ import {
LocalizationPipe, LocalizationPipe,
PagedResultDto, PagedResultDto,
ReplaceableTemplateDirective, ReplaceableTemplateDirective,
SSRService,
} from '@abp/ng.core'; } from '@abp/ng.core';
import { import {
eFeatureManagementComponents, eFeatureManagementComponents,
@ -25,7 +24,7 @@ import {
FormPropData, FormPropData,
generateFormFromProps, generateFormFromProps,
} from '@abp/ng.components/extensible'; } from '@abp/ng.components/extensible';
import { Component, inject, Injector, makeStateKey, OnInit, TransferState } from '@angular/core'; import { Component, inject, Injector, makeStateKey, OnInit } from '@angular/core';
import { import {
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
@ -69,7 +68,6 @@ export class TenantsComponent implements OnInit {
protected readonly toasterService = inject(ToasterService); protected readonly toasterService = inject(ToasterService);
private readonly fb = inject(UntypedFormBuilder); private readonly fb = inject(UntypedFormBuilder);
private readonly injector = inject(Injector); private readonly injector = inject(Injector);
private readonly ssrService = inject(SSRService);
data: PagedResultDto<TenantDto> = { items: [], totalCount: 0 }; data: PagedResultDto<TenantDto> = { items: [], totalCount: 0 };
@ -92,7 +90,7 @@ export class TenantsComponent implements OnInit {
return Boolean(this.selected.id); return Boolean(this.selected.id);
} }
constructor(private transferState: TransferState) {} constructor() {}
onVisibleFeaturesChange = (value: boolean) => { onVisibleFeaturesChange = (value: boolean) => {
this.visibleFeatures = value; this.visibleFeatures = value;
@ -157,19 +155,11 @@ export class TenantsComponent implements OnInit {
} }
hookToQuery() { hookToQuery() {
if (this.transferState.hasKey(this.TENANTS_KEY)) { this.list
this.data = this.transferState.get(this.TENANTS_KEY, { items: [], totalCount: 0 }); .hookToQuery(query => this.service.getList(query))
this.transferState.remove(this.TENANTS_KEY); .subscribe(res => {
} else { this.data = res;
this.list });
.hookToQuery(query => this.service.getList(query))
.subscribe(res => {
this.data = res;
if (this.ssrService.isServer) {
this.transferState.set(this.TENANTS_KEY, res);
}
});
}
} }
onSharedDatabaseChange(value: boolean) { onSharedDatabaseChange(value: boolean) {

Loading…
Cancel
Save