Skip to content

Commit

Permalink
refactor: remove client from frontend api (#6490)
Browse files Browse the repository at this point in the history
There was extra call getClient().getAll() not needed and complicating
readability.
  • Loading branch information
sjaanus committed Mar 11, 2024
1 parent 17ea8b3 commit 2997fae
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 11 deletions.
1 change: 0 additions & 1 deletion frontend/src/component/menu/Header/Header.tsx
Expand Up @@ -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 }) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/lib/proxy/client-feature-toggle-read-model-type.ts
@@ -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>>>;
}
8 changes: 1 addition & 7 deletions src/lib/proxy/client-feature-toggle-read-model.ts
Expand Up @@ -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`);
Expand Down Expand Up @@ -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();
}
}
2 changes: 1 addition & 1 deletion src/lib/proxy/fake-client-feature-toggle-read-model.ts
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/proxy/global-frontend-api-cache.ts
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2997fae

Please sign in to comment.