mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-22 16:03:39 +01:00
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 filter from 'lodash/filter';
|
||||||
import find from 'lodash/find';
|
import find from 'lodash/find';
|
||||||
|
|
||||||
export const doesRequestMatchSearchText = (request, searchText) => {
|
export const doesRequestMatchSearchText = (request, searchText = '') => {
|
||||||
return request.name.toLowerCase().includes(searchText.toLowerCase());
|
return request.name.toLowerCase().includes(searchText.toLowerCase());
|
||||||
};
|
};
|
||||||
|
|
||||||
export const doesFolderHaveItemsMatchSearchText = (item, searchText) => {
|
export const doesFolderHaveItemsMatchSearchText = (item, searchText = '') => {
|
||||||
let flattenedItems = flattenItems(item.items);
|
let flattenedItems = flattenItems(item.items);
|
||||||
let requestItems = filter(flattenedItems, (item) => isItemARequest(item));
|
let requestItems = filter(flattenedItems, (item) => isItemARequest(item));
|
||||||
|
|
||||||
return find(requestItems, (request) => doesRequestMatchSearchText(request, searchText));
|
return find(requestItems, (request) => doesRequestMatchSearchText(request, searchText));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const doesCollectionHaveItemsMatchingSearchText = (collection, searchText) => {
|
export const doesCollectionHaveItemsMatchingSearchText = (collection, searchText = '') => {
|
||||||
let flattenedItems = flattenItems(collection.items);
|
let flattenedItems = flattenItems(collection.items);
|
||||||
let requestItems = filter(flattenedItems, (item) => isItemARequest(item));
|
let requestItems = filter(flattenedItems, (item) => isItemARequest(item));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user