From e795e0f7949f8d64f992d11cc4dd45e1fad7129a Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Wed, 15 Nov 2023 16:31:25 +0000 Subject: [PATCH] recent limit set to 5 --- .../GlobalSearch/GlobalSearchList.jsx | 2 +- .../GlobalSearch/utils/searchUtils.js | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/ui/src/components/GlobalSearch/GlobalSearchList.jsx b/packages/ui/src/components/GlobalSearch/GlobalSearchList.jsx index 06ca4eaa6..31652f23e 100644 --- a/packages/ui/src/components/GlobalSearch/GlobalSearchList.jsx +++ b/packages/ui/src/components/GlobalSearch/GlobalSearchList.jsx @@ -227,7 +227,7 @@ function GlobalSearchList({ inputValue }) { )} {/* no input value search suggestions */} - {!inputValue && recentItems.length < 4 && SearchSuggestionEl} + {!inputValue && SearchSuggestionEl} ); } diff --git a/packages/ui/src/components/GlobalSearch/utils/searchUtils.js b/packages/ui/src/components/GlobalSearch/utils/searchUtils.js index 8e8e6dfee..3c64ad537 100644 --- a/packages/ui/src/components/GlobalSearch/utils/searchUtils.js +++ b/packages/ui/src/components/GlobalSearch/utils/searchUtils.js @@ -1,6 +1,6 @@ import { format } from "d3-format"; -const mapStandardKeys = (origionalKey) => { +const mapStandardKeys = origionalKey => { switch (origionalKey) { case "studyId": return "id"; @@ -17,7 +17,7 @@ const mapStandardKeys = (origionalKey) => { } }; -const flattenObj = (ob) => { +const flattenObj = ob => { const result = {}; Object.entries(ob).forEach(([key, value]) => { @@ -36,10 +36,10 @@ const flattenObj = (ob) => { return result; }; -const isArray = (value) => Array.isArray(value) && value.length > 0; +const isArray = value => Array.isArray(value) && value.length > 0; -const exceedsArrayLengthLimit = (array) => { - const limitLength = 9; +const exceedsArrayLengthLimit = array => { + const limitLength = 4; let exceedsLimit = false; if (array.length > limitLength) { @@ -48,13 +48,13 @@ const exceedsArrayLengthLimit = (array) => { return exceedsLimit; }; -export const formatSearchData = (unformattedData) => { +export const formatSearchData = unformattedData => { const formattedData = {}; Object.entries(unformattedData).forEach(([key, value]) => { const typesArray = []; if (isArray(value)) { - value.map((i) => + value.map(i => typesArray.push({ type: key === "topHit" ? "topHit" : key, entity: key, @@ -62,7 +62,7 @@ export const formatSearchData = (unformattedData) => { }) ); } else if (isArray(value.hits)) { - value.hits.map((i) => + value.hits.map(i => typesArray.push({ type: key === "topHit" ? "topHit" : i.entity, entity: i.entity, @@ -86,7 +86,7 @@ export const containsObject = (obj, list) => { return -1; }; -export const addSearchToLocalStorage = (item) => { +export const addSearchToLocalStorage = item => { const recentItems = JSON.parse(localStorage.getItem("search-history")) || []; const newItem = { ...item }; delete newItem.description; @@ -108,7 +108,7 @@ export const clearAllRecent = () => { window.dispatchEvent(new Event("storage")); }; -export const clearRecentItem = (item) => { +export const clearRecentItem = item => { const recentItems = JSON.parse(localStorage.getItem("search-history")); const removedItems = [...recentItems]; const existingIndex = containsObject(item, removedItems);