1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

refactor: remove client from frontend api (#6490)

There was extra call getClient().getAll() not needed and complicating
readability.
This commit is contained in:
Jaanus Sellin 2024-03-11 13:30:32 +02:00 committed by GitHub
parent 17ea8b3734
commit 2997faecf6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 4 additions and 11 deletions

View File

@ -39,7 +39,6 @@ import { Notifications } from 'component/common/Notifications/Notifications';
import { useAdminRoutes } from 'component/admin/useAdminRoutes';
import InviteLinkButton from './InviteLink/InviteLinkButton/InviteLinkButton';
import { useUiFlag } from 'hooks/useUiFlag';
import { INavigationMenuItem } from '../../../interfaces/route';
import { Badge } from '../../common/Badge/Badge';
const StyledHeader = styled(AppBar)(({ theme }) => ({

View File

@ -1,5 +1,5 @@
import { IFeatureToggleClient } from '../types';
export interface IClientFeatureToggleReadModel {
getClient(): Promise<Record<string, Record<string, IFeatureToggleClient>>>;
getAll(): Promise<Record<string, Record<string, IFeatureToggleClient>>>;
}

View File

@ -25,7 +25,7 @@ export default class ClientFeatureToggleReadModel
});
}
private async getAll(): Promise<
public async getAll(): Promise<
Record<string, Record<string, IFeatureToggleClient>>
> {
const stopTimer = this.timer(`getAll`);
@ -180,10 +180,4 @@ export default class ClientFeatureToggleReadModel
!feature.strategies?.find((s) => s?.id === row.strategy_id)
);
}
async getClient(): Promise<
Record<string, Record<string, IFeatureToggleClient>>
> {
return this.getAll();
}
}

View File

@ -11,7 +11,7 @@ export default class FakeClientFeatureToggleReadModel
> = {},
) {}
getClient(): Promise<Record<string, Record<string, IFeatureToggleClient>>> {
getAll(): Promise<Record<string, Record<string, IFeatureToggleClient>>> {
return Promise.resolve(this.value);
}

View File

@ -118,7 +118,7 @@ export class GlobalFrontendApiCache extends EventEmitter {
}
private async getAllFeatures(): Promise<FrontendApiFeatureCache> {
const features = await this.clientFeatureToggleReadModel.getClient();
const features = await this.clientFeatureToggleReadModel.getAll();
return this.mapFeatures(features);
}