From 83da88ca284635c1f13d02eefd5e5888414c3c5a Mon Sep 17 00:00:00 2001 From: summersamara Date: Mon, 27 Nov 2023 16:52:23 +0100 Subject: [PATCH] fix fullAddressAutocomplete component not loading results - introduce refetch method to fetch the result when query variables change --- .../Event/FullAddressAutoComplete.vue | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/Event/FullAddressAutoComplete.vue b/src/components/Event/FullAddressAutoComplete.vue index bfa911951..0302b737f 100644 --- a/src/components/Event/FullAddressAutoComplete.vue +++ b/src/components/Event/FullAddressAutoComplete.vue @@ -318,9 +318,10 @@ const debounceDelay = computed(() => geocodingAutocomplete.value === true ? 200 : 2000 ); -const { load: searchAddress } = useLazyQuery<{ - searchAddress: IAddress[]; -}>(ADDRESS); +const { load: searchAddressLoad, refetch: searchAddressRefetch } = + useLazyQuery<{ + searchAddress: IAddress[]; + }>(ADDRESS); const asyncData = async (query: string): Promise => { console.debug("Finding addresses"); @@ -338,13 +339,22 @@ const asyncData = async (query: string): Promise => { isFetching.value = true; try { - const result = await searchAddress(undefined, { + const queryVars = { query, locale: locale, 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); addressData.value = result.searchAddress; isFetching.value = false;