mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
fix(web): prevent change-location suggestion race-condition (#11523)
When debouncer activated on deletion, the handleSearchPlaces() function would fire a request with empty query. UI would then show Immich API error.
This commit is contained in:
parent
899b8a0ce7
commit
37cc6fbf27
1 changed files with 7 additions and 4 deletions
|
@ -69,15 +69,18 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSearchPlaces = () => {
|
const handleSearchPlaces = () => {
|
||||||
if (searchWord === '') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (latestSearchTimeout) {
|
if (latestSearchTimeout) {
|
||||||
clearTimeout(latestSearchTimeout);
|
clearTimeout(latestSearchTimeout);
|
||||||
}
|
}
|
||||||
showLoadingSpinner = true;
|
showLoadingSpinner = true;
|
||||||
|
|
||||||
const searchTimeout = window.setTimeout(() => {
|
const searchTimeout = window.setTimeout(() => {
|
||||||
|
if (searchWord === '') {
|
||||||
|
places = [];
|
||||||
|
showLoadingSpinner = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
searchPlaces({ name: searchWord })
|
searchPlaces({ name: searchWord })
|
||||||
.then((searchResult) => {
|
.then((searchResult) => {
|
||||||
// skip result when a newer search is happening
|
// skip result when a newer search is happening
|
||||||
|
|
Loading…
Reference in a new issue