diff --git a/app/soapbox/entity-store/hooks/useEntities.ts b/app/soapbox/entity-store/hooks/useEntities.ts index 3d3fddb489..6945ccd8db 100644 --- a/app/soapbox/entity-store/hooks/useEntities.ts +++ b/app/soapbox/entity-store/hooks/useEntities.ts @@ -131,7 +131,12 @@ function useEntities( const selectCache = (state: RootState, path: EntityPath) => state.entities[path[0]]; /** Get list at path from Redux. */ -const selectList = (state: RootState, path: EntityPath) => selectCache(state, path)?.lists[path[1]]; +const selectList = (state: RootState, path: EntityPath) => { + const [, ...listKeys] = path; + const listKey = listKeys.join(':'); + + return selectCache(state, path)?.lists[listKey]; +}; /** Select a particular item from a list state. */ function selectListState(state: RootState, path: EntityPath, key: K) { diff --git a/app/soapbox/entity-store/hooks/useEntity.ts b/app/soapbox/entity-store/hooks/useEntity.ts index 1dad1ff1e3..3c4b9cce7c 100644 --- a/app/soapbox/entity-store/hooks/useEntity.ts +++ b/app/soapbox/entity-store/hooks/useEntity.ts @@ -39,7 +39,7 @@ function useEntity( const fetchEntity = () => { setIsFetching(true); api.get(endpoint).then(({ data }) => { - const entity = schema.parse(data); + const entity = schema.parse(Array.isArray(data) ? data[0] : data); dispatch(importEntities([entity], entityType)); setIsFetching(false); }).catch(() => { diff --git a/app/soapbox/entity-store/hooks/useEntityActions.ts b/app/soapbox/entity-store/hooks/useEntityActions.ts index c1e40f37ee..58b6b0101f 100644 --- a/app/soapbox/entity-store/hooks/useEntityActions.ts +++ b/app/soapbox/entity-store/hooks/useEntityActions.ts @@ -65,7 +65,7 @@ function useEntityActions( } return { - createEntity: endpoints.post ? createEntity : undefined, + createEntity: createEntity, deleteEntity: endpoints.delete ? deleteEntity : undefined, }; }