mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 01:11:46 +03:00
feat(server): search unknown place (#10866)
* Allow submission of null country
* Update searchAssetBuilder to handle nulls
andWhere({country:null}) produces `"exifInfo"."country" = NULL`. We want
`"exifInfo"."country" IS NULL`, so we have to treat NULL as a special
case
* Allow null country in frontend
* Make the query code a bit more straightforward
* Remove unused brackets import
* Remove log message
* Don't change whitespace for no reason
* Fix prettier style issue
* Update search.dto.ts validators per @jrasm91's recommendation
* Update api types
* Combine null country and state into one guard clause
* chore: clean up
* chore: add e2e for null/empty city, state, country search
* refactor: server returns suggestion for null values
* chore: clean up
---------
Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
Co-authored-by: Jason Rasmussen <jason@rasm.me>
This commit is contained in:
@@ -6,9 +6,9 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { SearchSuggestionType, getSearchSuggestions } from '@immich/sdk';
|
||||
import Combobox, { toComboBoxOptions } from '../combobox.svelte';
|
||||
import Combobox, { asComboboxOptions, asSelectedOption } from '$lib/components/shared-components/combobox.svelte';
|
||||
import { handlePromiseError } from '$lib/utils';
|
||||
import { SearchSuggestionType, getSearchSuggestions } from '@immich/sdk';
|
||||
import { t } from 'svelte-i18n';
|
||||
|
||||
export let filters: SearchCameraFilter;
|
||||
@@ -22,17 +22,30 @@
|
||||
$: handlePromiseError(updateModels(makeFilter));
|
||||
|
||||
async function updateMakes(model?: string) {
|
||||
makes = await getSearchSuggestions({
|
||||
const results: Array<string | null> = await getSearchSuggestions({
|
||||
$type: SearchSuggestionType.CameraMake,
|
||||
model,
|
||||
includeNull: true,
|
||||
});
|
||||
if (filters.make && !makes.includes(filters.make)) {
|
||||
filters.make = undefined;
|
||||
}
|
||||
|
||||
makes = results.map((result) => result ?? '');
|
||||
}
|
||||
|
||||
async function updateModels(make?: string) {
|
||||
models = await getSearchSuggestions({
|
||||
const results: Array<string | null> = await getSearchSuggestions({
|
||||
$type: SearchSuggestionType.CameraModel,
|
||||
make,
|
||||
includeNull: true,
|
||||
});
|
||||
|
||||
const models = results.map((result) => result ?? '');
|
||||
|
||||
if (filters.model && !models.includes(filters.model)) {
|
||||
filters.model = undefined;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -44,9 +57,9 @@
|
||||
<Combobox
|
||||
label={$t('make')}
|
||||
on:select={({ detail }) => (filters.make = detail?.value)}
|
||||
options={toComboBoxOptions(makes)}
|
||||
options={asComboboxOptions(makes)}
|
||||
placeholder={$t('search_camera_make')}
|
||||
selectedOption={makeFilter ? { label: makeFilter, value: makeFilter } : undefined}
|
||||
selectedOption={asSelectedOption(makeFilter)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -54,9 +67,9 @@
|
||||
<Combobox
|
||||
label={$t('model')}
|
||||
on:select={({ detail }) => (filters.model = detail?.value)}
|
||||
options={toComboBoxOptions(models)}
|
||||
options={asComboboxOptions(models)}
|
||||
placeholder={$t('search_camera_model')}
|
||||
selectedOption={modelFilter ? { label: modelFilter, value: modelFilter } : undefined}
|
||||
selectedOption={asSelectedOption(modelFilter)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user