Skip to content

Commit

Permalink
fix(chat): fix prompt applying for admin (Issue #1967) (#1968)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Kezik authored and sergesha committed Aug 26, 2024
1 parent 9c9be4f commit c7b6e05
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
5 changes: 2 additions & 3 deletions apps/chat/src/components/Chat/ChatInput/PromptList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ export const PromptList: FC<Props> = ({
},
});
const promptResources = useAppSelector((state) =>
PublicationSelectors.selectFilteredPublicationResources(
state,
PublicationSelectors.selectFilteredPublicationResources(state, [
FeatureType.Prompt,
),
]),
);

const dismiss = useDismiss(context);
Expand Down
26 changes: 16 additions & 10 deletions apps/chat/src/store/publication/publication.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,25 @@ export const selectPublications = createSelector([rootSelector], (state) => {

export const selectFilteredPublications = createSelector(
[
rootSelector,
selectPublications,
(_state, featureTypes: FeatureType[]) => featureTypes,
(_state, _featureTypes, includeEmptyResourceTypes?: boolean) =>
includeEmptyResourceTypes,
(
_state,
_featureTypes: FeatureType[],
includeEmptyResourceTypes?: boolean,
) => includeEmptyResourceTypes,
],
(state, featureTypes, includeEmptyResourceTypes) => {
return state.publications.filter(
(p) =>
p.resourceTypes.some((resourceType) =>
(publications, featureTypes, includeEmptyResourceTypes) => {
return publications.filter(
(publication) =>
publication.resourceTypes.some((resourceType) =>
featureTypes
.map((featureType) =>
EnumMapper.getBackendResourceTypeByFeatureType(featureType),
)
.includes(resourceType),
) ||
(includeEmptyResourceTypes && !p.resourceTypes.length),
(includeEmptyResourceTypes && !publication.resourceTypes.length),
);
},
);
Expand Down Expand Up @@ -185,8 +188,11 @@ export const selectPublicationsToReviewCount = createSelector(
selectPublications,
selectResourcesToReview,
(_state, featureTypes: FeatureType[]) => featureTypes,
(_state, _featureTypes, includeEmptyFeatureTypes?: boolean) =>
includeEmptyFeatureTypes,
(
_state,
_featureTypes: FeatureType[],
includeEmptyFeatureTypes?: boolean,
) => includeEmptyFeatureTypes,
],
(publications, resourcesToReview, featureTypes, includeEmptyFeatureTypes) => {
const filteredPublications = publications.filter(
Expand Down

0 comments on commit c7b6e05

Please sign in to comment.