Skip to content

Commit

Permalink
fix: fix prompts search (Issue epam#330) (epam#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Kezik authored Jan 17, 2024
1 parent 9ad4d4f commit 36ff596
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/store/conversations/conversations.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export const selectFilteredFolders = createSelector(
includeEmptyFolders?,
) =>
getFilteredFolders(
state,
folders,
emptyFolderIds,
filters,
selectFilteredConversations(state, filters, searchTerm),
searchTerm,
includeEmptyFolders,
),
Expand Down
2 changes: 1 addition & 1 deletion src/store/prompts/prompts.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export const selectFilteredFolders = createSelector(
includeEmptyFolders?,
) =>
getFilteredFolders(
state,
folders,
emptyFolderIds,
filters,
selectFilteredPrompts(state, filters, searchTerm),
searchTerm,
includeEmptyFolders,
),
Expand Down
15 changes: 2 additions & 13 deletions src/utils/app/folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import { FolderInterface } from '@/src/types/folder';
import { Prompt } from '@/src/types/prompt';
import { EntityFilters } from '@/src/types/search';

import { selectFilteredConversations } from '@/src/store/conversations/conversations.selectors';

import { RootState } from '@/src/store';

export const getFoldersDepth = (
childFolder: FolderInterface,
allFolders: FolderInterface[],
Expand Down Expand Up @@ -204,21 +200,14 @@ export const getPathToFolderById = (
};

export const getFilteredFolders = (
state: RootState,
folders: FolderInterface[],
emptyFolderIds: string[],
filters: EntityFilters,
entities: Conversation[] | Prompt[],
searchTerm?: string,
includeEmptyFolders?: boolean,
) => {
const filteredConversations = selectFilteredConversations(
state,
filters,
searchTerm,
);
const folderIds = filteredConversations
.map((c) => c.folderId)
.filter((fid) => fid);
const folderIds = entities.map((c) => c.folderId).filter((fid) => fid);

if (!searchTerm?.trim().length) {
const markedFolderIds = folders
Expand Down

0 comments on commit 36ff596

Please sign in to comment.