1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-28 22:51:59 +00:00

fix(web): show search page errors and use feature flag (#8088)

This commit is contained in:
Michel Heusschen 2024-03-20 13:24:08 +01:00 committed by GitHub
parent 9c6a26de9f
commit e810aae212
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,6 +37,8 @@
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
import { handlePromiseError } from '$lib/utils';
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;
let { isViewing: showAssetViewer } = assetViewingStore;
@ -98,11 +100,12 @@
type SearchTerms = MetadataSearchDto & Pick<SmartSearchDto, 'query'>;
$: searchQuery = $page.url.searchParams.get(QueryParameter.QUERY);
$: terms = ((): SearchTerms => {
return searchQuery ? JSON.parse(searchQuery) : {};
})();
let terms: SearchTerms;
$: terms = searchQuery ? JSON.parse(searchQuery) : {};
$: terms, handlePromiseError(onSearchQueryUpdate());
$: if (terms && $featureFlags.loaded) {
handlePromiseError(onSearchQueryUpdate());
}
async function onSearchQueryUpdate() {
nextPage = 1;
@ -124,18 +127,23 @@
...terms,
};
const { albums, assets } =
'query' in searchDto
? await searchSmart({ smartSearchDto: searchDto })
: await searchMetadata({ metadataSearchDto: searchDto });
try {
const { albums, assets } =
'query' in searchDto && $featureFlags.smartSearch
? await searchSmart({ smartSearchDto: searchDto })
: await searchMetadata({ metadataSearchDto: searchDto });
searchResultAlbums.push(...albums.items);
searchResultAssets.push(...assets.items);
searchResultAlbums = searchResultAlbums;
searchResultAssets = searchResultAssets;
searchResultAlbums.push(...albums.items);
searchResultAssets.push(...assets.items);
searchResultAlbums = searchResultAlbums;
searchResultAssets = searchResultAssets;
nextPage = assets.nextPage ? Number(assets.nextPage) : null;
isLoading = false;
nextPage = assets.nextPage ? Number(assets.nextPage) : null;
} catch (error) {
handleError(error, 'Loading search results failed');
} finally {
isLoading = false;
}
};
function getHumanReadableDate(dateString: string) {