From 83da88ca284635c1f13d02eefd5e5888414c3c5a Mon Sep 17 00:00:00 2001 From: summersamara Date: Mon, 27 Nov 2023 16:52:23 +0100 Subject: [PATCH 1/3] 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; From f81804d57fa5659498b8e5cf4cd91a3e88d15643 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 27 Nov 2023 16:43:12 +0000 Subject: [PATCH 2/3] resolve result promise in a shorter way --- src/components/Event/FullAddressAutoComplete.vue | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/Event/FullAddressAutoComplete.vue b/src/components/Event/FullAddressAutoComplete.vue index 0302b737f..a9f687f08 100644 --- a/src/components/Event/FullAddressAutoComplete.vue +++ b/src/components/Event/FullAddressAutoComplete.vue @@ -347,9 +347,7 @@ const asyncData = async (query: string): Promise => { const result = (await searchAddressLoad(undefined, queryVars)) || - (await searchAddressRefetch(queryVars)?.then((object) => { - return object.data; - })); + (await searchAddressRefetch(queryVars))?.data if (!result) { isFetching.value = false; From 49b070d9393b89f0f88438a5151239db3765c34a Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 30 Nov 2023 09:45:25 +0100 Subject: [PATCH 3/3] fix(api): allow localhost as a valid uri host for applications Signed-off-by: Thomas Citharel --- lib/web/controllers/application_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/controllers/application_controller.ex b/lib/web/controllers/application_controller.ex index 7ef7d5600..a08960f12 100644 --- a/lib/web/controllers/application_controller.ex +++ b/lib/web/controllers/application_controller.ex @@ -426,7 +426,7 @@ defmodule Mobilizon.Web.ApplicationController do defp valid_uri?(url) do uri = URI.parse(url) - uri.scheme != nil and uri.host =~ "." + uri.scheme != nil and (uri.host =~ "." or uri.host == "localhost") end @spec append_parameters(String.t(), Enum.t()) :: String.t()