From b665ff25a49649062c81acba6567e5b5f2194a19 Mon Sep 17 00:00:00 2001 From: guido Date: Tue, 15 Aug 2023 12:03:30 +0200 Subject: [PATCH] `ResolveStatus` must be private of `useEntityRecords` --- @types/index.d.ts | 6 ------ sources/js/src/hooks/use-entity-records.ts | 10 ++++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/@types/index.d.ts b/@types/index.d.ts index f9fa108..c5bbc99 100644 --- a/@types/index.d.ts +++ b/@types/index.d.ts @@ -5,12 +5,6 @@ import { BaseEntityRecords, Context } from '@wordpress/core-data'; export default EntitiesSearch; declare namespace EntitiesSearch { - enum ResolveStatus { - ERROR = 'ERROR', - SUCCESS = 'SUCCESS', - RESOLVING = 'RESOLVING', - } - type PostType = BaseEntityRecords.Type; type ViewablePostType = Readonly<{ diff --git a/sources/js/src/hooks/use-entity-records.ts b/sources/js/src/hooks/use-entity-records.ts index 9dd3c73..c21d33e 100644 --- a/sources/js/src/hooks/use-entity-records.ts +++ b/sources/js/src/hooks/use-entity-records.ts @@ -3,6 +3,12 @@ import { Set } from 'immutable'; import { useEntityRecords as useCoreEntityRecords } from '@wordpress/core-data'; +enum ResolveStatus { + ERROR = 'ERROR', + SUCCESS = 'SUCCESS', + RESOLVING = 'RESOLVING', +} + /** * The hook will return an empty collection while resolving. * This is to guarantee a better flow in the data manipulation, therefore do not count on the data returned by the @@ -19,14 +25,14 @@ export function useEntityRecords( queryArgs: Record = {} ): EntitiesSearch.EntitiesRecords { const entities = useCoreEntityRecords(kind, name, queryArgs); - const status = entities.status as any as EntitiesSearch.ResolveStatus; + const status = entities.status as any as ResolveStatus; return Object.freeze({ records: () => Set(entities.records ?? []), isResolving: () => entities.isResolving && !entities.hasResolved && - status === EntitiesSearch.ResolveStatus.RESOLVING, + status === ResolveStatus.RESOLVING, errored: () => makeStatusCallback(entities, 'ERROR'), succeed: () => makeStatusCallback(entities, 'SUCCESS'), });