refactor: simplify recent searches handling in MarketSearchBar

- Updated recent searches logic to directly manipulate the recentSearches value, improving clarity and reducing complexity.
- Changed the filtering mechanism to use a more straightforward approach, enhancing maintainability.

These changes streamline the recent searches functionality, contributing to a cleaner and more efficient MarketSearchBar component.
This commit is contained in:
padreug 2025-09-27 21:23:40 +02:00
parent 3d5f1230e7
commit bdc74f9c90

View file

@ -338,14 +338,15 @@ const applyRecentSearch = (recent: string) => {
const addToRecentSearches = (query: string) => {
if (!props.showEnhancements) return
const searches = recentSearches.value.value.filter(s => s !== query)
const currentSearches = recentSearches.value as string[]
const searches = currentSearches.filter((s: string) => s !== query)
searches.unshift(query)
recentSearches.value.value = searches.slice(0, 10) // Keep only 10 recent searches
recentSearches.value = searches.slice(0, 10) as any // Keep only 10 recent searches
}
const clearRecentSearches = () => {
if (props.showEnhancements) {
recentSearches.value.value = []
recentSearches.value = [] as any
}
}