mirror of
https://github.com/immich-app/immich.git
synced 2025-12-15 09:13:11 +03:00
Compare commits
2 Commits
chore/log-
...
fix/search
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6873ca8685 | ||
|
|
33cdea88aa |
@@ -17,8 +17,10 @@ class PersonApiRepository extends ApiRepository {
|
||||
}
|
||||
|
||||
Future<PersonDto> update(String id, {String? name, DateTime? birthday}) async {
|
||||
final dto = await checkNull(_api.updatePerson(id, PersonUpdateDto(name: name, birthDate: birthday)));
|
||||
return _toPerson(dto);
|
||||
final birthdayUtc = birthday == null ? null : DateTime.utc(birthday.year, birthday.month, birthday.day);
|
||||
final dto = PersonUpdateDto(name: name, birthDate: birthdayUtc);
|
||||
final response = await checkNull(_api.updatePerson(id, dto));
|
||||
return _toPerson(response);
|
||||
}
|
||||
|
||||
static PersonDto _toPerson(PersonResponseDto dto) => PersonDto(
|
||||
|
||||
@@ -79,10 +79,25 @@
|
||||
searchStore.isSearchEnabled = false;
|
||||
};
|
||||
|
||||
function buildSearchPayload(term: string): SmartSearchDto | MetadataSearchDto {
|
||||
const searchType = getSearchType();
|
||||
switch (searchType) {
|
||||
case 'smart':
|
||||
return { query: term } as SmartSearchDto;
|
||||
case 'metadata':
|
||||
return { originalFileName: term } as MetadataSearchDto;
|
||||
case 'description':
|
||||
return { description: term } as MetadataSearchDto;
|
||||
case 'ocr':
|
||||
return { ocr: term } as MetadataSearchDto;
|
||||
default:
|
||||
return { query: term } as SmartSearchDto;
|
||||
}
|
||||
}
|
||||
|
||||
const onHistoryTermClick = async (searchTerm: string) => {
|
||||
value = searchTerm;
|
||||
const searchPayload = { query: searchTerm };
|
||||
await handleSearch(searchPayload);
|
||||
await handleSearch(buildSearchPayload(searchTerm));
|
||||
};
|
||||
|
||||
const onFilterClick = async () => {
|
||||
@@ -112,29 +127,7 @@
|
||||
};
|
||||
|
||||
const onSubmit = () => {
|
||||
const searchType = getSearchType();
|
||||
let payload = {} as SmartSearchDto | MetadataSearchDto;
|
||||
|
||||
switch (searchType) {
|
||||
case 'smart': {
|
||||
payload = { query: value } as SmartSearchDto;
|
||||
break;
|
||||
}
|
||||
case 'metadata': {
|
||||
payload = { originalFileName: value } as MetadataSearchDto;
|
||||
break;
|
||||
}
|
||||
case 'description': {
|
||||
payload = { description: value } as MetadataSearchDto;
|
||||
break;
|
||||
}
|
||||
case 'ocr': {
|
||||
payload = { ocr: value } as MetadataSearchDto;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
handlePromiseError(handleSearch(payload));
|
||||
handlePromiseError(handleSearch(buildSearchPayload(value)));
|
||||
saveSearchTerm(value);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user