feat(topbar): drop search box to reclaim filter-bar space
The search box on the right edge of the filter bar wasn't pulling its weight — kills it entirely along with the supporting plumbing: - FilterBar: remove input + Search icon import + local/debounced state - filterStore: drop `q`, `setQ`, plus all references in INITIAL_FILTERS, filtersToParams, hasActiveFilters, snapshotFilters - usePhotosQuery: stop passing q through filtersToParams - useFilterUrlSync: drop the `q` URL param read/write - PhotoThumbnail + PreviewView: remove the search-match banner/chip and findSearchMatch helper imports - Timeline + MemoriesView: stop subscribing to / forwarding the prop - useKeyboardShortcuts: drop the `/` and Cmd+F focus hotkeys - KeyboardHints: drop the `/` hint and the now-stale `?` collision note - delete hooks/useSearchQuery.ts (no callers) and lib/searchMatch.ts Backend /photos/search endpoint left untouched — no UI reaches it now. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -37,9 +37,6 @@ function parseUrl(): HydratePayload {
|
||||
const sp = new URLSearchParams(window.location.search)
|
||||
const out: HydratePayload = {}
|
||||
|
||||
const q = sp.get('q')
|
||||
if (q) out.q = q
|
||||
|
||||
const df = sp.get('date_from')
|
||||
if (df) out.dateFrom = df
|
||||
|
||||
@@ -112,7 +109,6 @@ function parseUrl(): HydratePayload {
|
||||
|
||||
function writeUrl(f: FilterState & { currentSection?: string }) {
|
||||
const sp = new URLSearchParams()
|
||||
if (f.q.trim()) sp.set('q', f.q.trim())
|
||||
if (f.dateFrom) sp.set('date_from', f.dateFrom)
|
||||
if (f.dateTo) sp.set('date_to', f.dateTo)
|
||||
if (f.mediaTypes.length > 0) sp.set('media_type', f.mediaTypes.join(','))
|
||||
|
||||
@@ -403,15 +403,6 @@ export function useKeyboardShortcuts(props: KeyboardShortcutsProps) {
|
||||
HK_OPTS
|
||||
)
|
||||
|
||||
// Search focus (/ or Cmd/Ctrl+F).
|
||||
const focusSearch = () => {
|
||||
const el = document.getElementById('topbar-search') as HTMLInputElement | null
|
||||
el?.focus()
|
||||
el?.select()
|
||||
}
|
||||
useHotkeys('/', focusSearch, HK_OPTS)
|
||||
useHotkeys('mod+f', focusSearch, HK_OPTS)
|
||||
|
||||
// Space toggles the preview view (open from grid, close from preview).
|
||||
// Double-click on a thumbnail does the same.
|
||||
const openPreviewFromGrid = () => {
|
||||
|
||||
@@ -49,7 +49,6 @@ export function usePhotosQuery() {
|
||||
const filterParams = useFilterStore(
|
||||
useShallow((s) =>
|
||||
filtersToParams({
|
||||
q: s.q,
|
||||
dateFrom: s.dateFrom,
|
||||
dateTo: s.dateTo,
|
||||
mediaTypes: s.mediaTypes,
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { search, type SearchResult } from '../services/api'
|
||||
import { useFilterStore } from '../store/filterStore'
|
||||
|
||||
/**
|
||||
* Hybrid search hook — fires POST /photos/search when the user has a
|
||||
* non-empty search query. Returns results ranked by RRF (FTS + semantic).
|
||||
*
|
||||
* When `q` is empty, this hook is disabled and returns no data — the
|
||||
* normal usePhotosQuery takes over for browse mode.
|
||||
*/
|
||||
export function useSearchQuery() {
|
||||
const q = useFilterStore((s) => s.q)
|
||||
const tagIds = useFilterStore((s) => s.tagIds)
|
||||
const dateFrom = useFilterStore((s) => s.dateFrom)
|
||||
const dateTo = useFilterStore((s) => s.dateTo)
|
||||
|
||||
const hasQuery = q.trim().length > 0
|
||||
|
||||
return useQuery<SearchResult[]>({
|
||||
queryKey: ['search', q, tagIds, dateFrom, dateTo],
|
||||
queryFn: async () => {
|
||||
const resp = await search.query({
|
||||
q: q.trim(),
|
||||
filters: {
|
||||
tag_ids: tagIds.length > 0 ? tagIds : undefined,
|
||||
date_from: dateFrom ?? undefined,
|
||||
date_to: dateTo ?? undefined,
|
||||
},
|
||||
limit: 200,
|
||||
})
|
||||
return resp.results
|
||||
},
|
||||
enabled: hasQuery,
|
||||
staleTime: 30_000,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user