69983ff83a
* feat: hybrid search * fixing normal search * building out the query * okla * filters * date * order by date * Remove hybrid search endpoint * remove search hybrid endpoint * faces query * search for person * search and pagination * with exif * with exif * justify gallery viewer * memory view * Fixed userId is null * openapi and styling * searchdto * lint and format * remove term * generate sql * fix test * chips * not showing true * pr feedback * pr feedback * nit name * linting * pr feedback * styling * linting
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { QueryParameter } from '$lib/constants';
|
|
import { searchQuery } from '$lib/stores/search.store';
|
|
import { authenticate } from '$lib/utils/auth';
|
|
import {
|
|
searchMetadata,
|
|
searchSmart,
|
|
type MetadataSearchDto,
|
|
type SearchResponseDto,
|
|
type SmartSearchDto,
|
|
} from '@immich/sdk';
|
|
import type { PageLoad } from './$types';
|
|
|
|
export const load = (async (data) => {
|
|
await authenticate();
|
|
const url = new URL(data.url.href);
|
|
const term =
|
|
url.searchParams.get(QueryParameter.SEARCH_TERM) || url.searchParams.get(QueryParameter.QUERY) || undefined;
|
|
let results: SearchResponseDto | null = null;
|
|
if (term) {
|
|
const payload = JSON.parse(term) as SmartSearchDto | MetadataSearchDto;
|
|
searchQuery.set(payload);
|
|
|
|
results =
|
|
payload && 'query' in payload
|
|
? await searchSmart({ smartSearchDto: { ...payload, withExif: true } })
|
|
: await searchMetadata({ metadataSearchDto: { ...payload, withExif: true } });
|
|
}
|
|
|
|
return {
|
|
term,
|
|
results,
|
|
meta: {
|
|
title: 'Search',
|
|
},
|
|
};
|
|
}) satisfies PageLoad;
|