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

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

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

Loading…
Cancel
Save