mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-13 15:51:00 +00:00
f7782b9ef7
The search box of the places list matched only name and address. It now also reads what was written about a place, through one helper the desktop list, its filter counts and the phone's browser share. (#2252)
19 lines
772 B
TypeScript
19 lines
772 B
TypeScript
import type { Place } from '../types'
|
|
|
|
type Searchable = Pick<Place, 'name' | 'address' | 'description' | 'notes'>
|
|
|
|
/**
|
|
* Whether a place matches the search box of the places list (#2252). Name and
|
|
* address as before, and also the description and the notes, so a place found
|
|
* by what was written about it ("vegan", "book ahead") turns up too. One helper
|
|
* for the desktop list, its filter counts and the phone's browser, so the three
|
|
* can never disagree about what a search finds.
|
|
*/
|
|
export function placeMatchesSearch(place: Searchable, query: string): boolean {
|
|
const q = query.trim().toLowerCase()
|
|
if (!q) return true
|
|
return [place.name, place.address, place.description, place.notes].some(
|
|
field => !!field && field.toLowerCase().includes(q),
|
|
)
|
|
}
|