mirror of
https://github.com/immich-app/immich.git
synced 2025-01-21 00:52:43 -05:00
fix(web): show search page errors and use feature flag (#8088)
This commit is contained in:
parent
9c6a26de9f
commit
e810aae212
1 changed files with 22 additions and 14 deletions
|
@ -37,6 +37,8 @@
|
||||||
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
|
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
|
||||||
import { handlePromiseError } from '$lib/utils';
|
import { handlePromiseError } from '$lib/utils';
|
||||||
import { parseUtcDate } from '$lib/utils/date-time';
|
import { parseUtcDate } from '$lib/utils/date-time';
|
||||||
|
import { featureFlags } from '$lib/stores/server-config.store';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
|
||||||
const MAX_ASSET_COUNT = 5000;
|
const MAX_ASSET_COUNT = 5000;
|
||||||
let { isViewing: showAssetViewer } = assetViewingStore;
|
let { isViewing: showAssetViewer } = assetViewingStore;
|
||||||
|
@ -98,11 +100,12 @@
|
||||||
type SearchTerms = MetadataSearchDto & Pick<SmartSearchDto, 'query'>;
|
type SearchTerms = MetadataSearchDto & Pick<SmartSearchDto, 'query'>;
|
||||||
|
|
||||||
$: searchQuery = $page.url.searchParams.get(QueryParameter.QUERY);
|
$: searchQuery = $page.url.searchParams.get(QueryParameter.QUERY);
|
||||||
$: terms = ((): SearchTerms => {
|
let terms: SearchTerms;
|
||||||
return searchQuery ? JSON.parse(searchQuery) : {};
|
$: terms = searchQuery ? JSON.parse(searchQuery) : {};
|
||||||
})();
|
|
||||||
|
|
||||||
$: terms, handlePromiseError(onSearchQueryUpdate());
|
$: if (terms && $featureFlags.loaded) {
|
||||||
|
handlePromiseError(onSearchQueryUpdate());
|
||||||
|
}
|
||||||
|
|
||||||
async function onSearchQueryUpdate() {
|
async function onSearchQueryUpdate() {
|
||||||
nextPage = 1;
|
nextPage = 1;
|
||||||
|
@ -124,18 +127,23 @@
|
||||||
...terms,
|
...terms,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { albums, assets } =
|
try {
|
||||||
'query' in searchDto
|
const { albums, assets } =
|
||||||
? await searchSmart({ smartSearchDto: searchDto })
|
'query' in searchDto && $featureFlags.smartSearch
|
||||||
: await searchMetadata({ metadataSearchDto: searchDto });
|
? await searchSmart({ smartSearchDto: searchDto })
|
||||||
|
: await searchMetadata({ metadataSearchDto: searchDto });
|
||||||
|
|
||||||
searchResultAlbums.push(...albums.items);
|
searchResultAlbums.push(...albums.items);
|
||||||
searchResultAssets.push(...assets.items);
|
searchResultAssets.push(...assets.items);
|
||||||
searchResultAlbums = searchResultAlbums;
|
searchResultAlbums = searchResultAlbums;
|
||||||
searchResultAssets = searchResultAssets;
|
searchResultAssets = searchResultAssets;
|
||||||
|
|
||||||
nextPage = assets.nextPage ? Number(assets.nextPage) : null;
|
nextPage = assets.nextPage ? Number(assets.nextPage) : null;
|
||||||
isLoading = false;
|
} catch (error) {
|
||||||
|
handleError(error, 'Loading search results failed');
|
||||||
|
} finally {
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function getHumanReadableDate(dateString: string) {
|
function getHumanReadableDate(dateString: string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue