A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix: dedup list and recent search suggestions
Mohamed Bassem8539c836cd85
diff --git a/apps/web/components/dashboard/search/useSearchAutocomplete.ts b/apps/web/components/dashboard/search/useSearchAutocomplete.tsindex f98f23f5..c72f4fc5 100644--- a/apps/web/components/dashboard/search/useSearchAutocomplete.ts+++ b/apps/web/components/dashboard/search/useSearchAutocomplete.ts@@ -372,6 +372,7 @@ const useListSuggestions = (}const lists = listResults?.data ?? [];+ const seenListNames = new Set<string>();return lists.filter((list) => {@@ -380,6 +381,15 @@ const useListSuggestions = (}return list.name.toLowerCase().includes(normalizedListSearchTerm);})+ .filter((list) => {+ const normalizedListName = list.name.trim().toLowerCase();+ if (seenListNames.has(normalizedListName)) {+ return false;+ }++ seenListNames.add(normalizedListName);+ return true;+ }).slice(0, MAX_DISPLAY_SUGGESTIONS).map((list) => {const formattedName = formatSearchValue(list.name);@@ -450,6 +460,7 @@ const useHistorySuggestions = (): HistorySuggestionItem[] => {const historyItems = useMemo<HistorySuggestionItem[]>(() => {const trimmedValue = value.trim();+ const seenTerms = new Set<string>();const results =trimmedValue.length === 0? history@@ -457,16 +468,27 @@ const useHistorySuggestions = (item.toLowerCase().includes(trimmedValue.toLowerCase()),);- return results.slice(0, MAX_DISPLAY_SUGGESTIONS).map(- (term) =>- ({- type: "history" as const,- id: `history-${term}`,- term,- label: term,- Icon: History,- }) satisfies HistorySuggestionItem,- );+ return results+ .filter((term) => {+ const normalizedTerm = term.trim().toLowerCase();+ if (seenTerms.has(normalizedTerm)) {+ return false;+ }++ seenTerms.add(normalizedTerm);+ return true;+ })+ .slice(0, MAX_DISPLAY_SUGGESTIONS)+ .map(+ (term) =>+ ({+ type: "history" as const,+ id: `history-${term}`,+ term,+ label: term,+ Icon: History,+ }) satisfies HistorySuggestionItem,+ );}, [history, value]);return historyItems;