forked from extern/bruno
chore: added null safety while searching
This commit is contained in:
parent
77568da03c
commit
62e9f4d5f0
@ -2,18 +2,18 @@ import { flattenItems, isItemARequest } from "./index";
|
||||
import filter from 'lodash/filter';
|
||||
import find from 'lodash/find';
|
||||
|
||||
export const doesRequestMatchSearchText = (request, searchText) => {
|
||||
export const doesRequestMatchSearchText = (request, searchText = '') => {
|
||||
return request.name.toLowerCase().includes(searchText.toLowerCase());
|
||||
};
|
||||
|
||||
export const doesFolderHaveItemsMatchSearchText = (item, searchText) => {
|
||||
export const doesFolderHaveItemsMatchSearchText = (item, searchText = '') => {
|
||||
let flattenedItems = flattenItems(item.items);
|
||||
let requestItems = filter(flattenedItems, (item) => isItemARequest(item));
|
||||
|
||||
return find(requestItems, (request) => doesRequestMatchSearchText(request, searchText));
|
||||
};
|
||||
|
||||
export const doesCollectionHaveItemsMatchingSearchText = (collection, searchText) => {
|
||||
export const doesCollectionHaveItemsMatchingSearchText = (collection, searchText = '') => {
|
||||
let flattenedItems = flattenItems(collection.items);
|
||||
let requestItems = filter(flattenedItems, (item) => isItemARequest(item));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user