fix fullAddressAutocomplete component not loading results
- introduce refetch method to fetch the result when query variables change
This commit is contained in:
parent
ad597db271
commit
83da88ca28
@ -318,9 +318,10 @@ const debounceDelay = computed(() =>
|
|||||||
geocodingAutocomplete.value === true ? 200 : 2000
|
geocodingAutocomplete.value === true ? 200 : 2000
|
||||||
);
|
);
|
||||||
|
|
||||||
const { load: searchAddress } = useLazyQuery<{
|
const { load: searchAddressLoad, refetch: searchAddressRefetch } =
|
||||||
searchAddress: IAddress[];
|
useLazyQuery<{
|
||||||
}>(ADDRESS);
|
searchAddress: IAddress[];
|
||||||
|
}>(ADDRESS);
|
||||||
|
|
||||||
const asyncData = async (query: string): Promise<void> => {
|
const asyncData = async (query: string): Promise<void> => {
|
||||||
console.debug("Finding addresses");
|
console.debug("Finding addresses");
|
||||||
@ -338,13 +339,22 @@ const asyncData = async (query: string): Promise<void> => {
|
|||||||
isFetching.value = true;
|
isFetching.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await searchAddress(undefined, {
|
const queryVars = {
|
||||||
query,
|
query,
|
||||||
locale: locale,
|
locale: locale,
|
||||||
type: props.resultType,
|
type: props.resultType,
|
||||||
});
|
};
|
||||||
|
|
||||||
if (!result) return;
|
const result =
|
||||||
|
(await searchAddressLoad(undefined, queryVars)) ||
|
||||||
|
(await searchAddressRefetch(queryVars)?.then((object) => {
|
||||||
|
return object.data;
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
isFetching.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
console.debug("onAddressSearchResult", result.searchAddress);
|
console.debug("onAddressSearchResult", result.searchAddress);
|
||||||
addressData.value = result.searchAddress;
|
addressData.value = result.searchAddress;
|
||||||
isFetching.value = false;
|
isFetching.value = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user