Merge branch 'mobilizon-fix-full-address-autocomplete-not-loading-result'

This commit is contained in:
Thomas Citharel 2023-11-30 09:46:23 +01:00
commit 1a4c4b41e3
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
2 changed files with 15 additions and 7 deletions

View File

@ -426,7 +426,7 @@ defmodule Mobilizon.Web.ApplicationController do
defp valid_uri?(url) do defp valid_uri?(url) do
uri = URI.parse(url) uri = URI.parse(url)
uri.scheme != nil and uri.host =~ "." uri.scheme != nil and (uri.host =~ "." or uri.host == "localhost")
end end
@spec append_parameters(String.t(), Enum.t()) :: String.t() @spec append_parameters(String.t(), Enum.t()) :: String.t()

View File

@ -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,20 @@ 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))?.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;