diff --git a/src/Shell.tsx b/src/Shell.tsx index 98e632473a..ec38b0d052 100644 --- a/src/Shell.tsx +++ b/src/Shell.tsx @@ -90,18 +90,13 @@ class ShellContainer extends React.Component implements ShellFunct } } - debounceCall = debounce(async (queryString: string, type: string, param: string) => { + debounceCall = debounce(async (queryString: string, action: string, param: string) => { const replacedQueryString = queryString .normalize("NFKD") .replace(/[^\w]/g, ""); - - const action = type === "repository" ? "autosuggest-repository" : "autosuggest"; - // use replaced query string with old autosuggest - const useReplacedQueryString = action === "autosuggest" - const query = useReplacedQueryString ? replacedQueryString : encodeURIComponent(queryString) const res = await fetch( - `https://${this.props.botId}.azurewebsites.net/webchat/${action}/${query}/${param}` + `https://${this.props.botId}.azurewebsites.net/webchat/${action}/${replacedQueryString}/${param}` ); const data = await res.json(); @@ -114,11 +109,12 @@ class ShellContainer extends React.Component implements ShellFunct }, 500); private autoSuggestOnKeyUp = (e: React.KeyboardEvent) => { - if (this.props.autoSuggestType === "google-city") { + if (this.props.autoSuggestType === "google-places-city") { this.debounceCall(e.currentTarget.value, this.props.autoSuggestType, this.props.autoSuggestCountry); } if(this.props.autoSuggestType === "repository") { - this.debounceCall(e.currentTarget.value, this.props.autoSuggestType, this.props.autoSuggestSource) + const queryString = encodeURIComponent(e.currentTarget.value) + this.debounceCall(queryString, this.props.autoSuggestType, this.props.autoSuggestSource) } }; diff --git a/src/Store.ts b/src/Store.ts index d1c93f049e..25409f34b9 100644 --- a/src/Store.ts +++ b/src/Store.ts @@ -751,7 +751,7 @@ const showAutoSuggestBasedOnChannelData: Epic = ( showAutoSuggest: typeof action.activity.channelData === "object" && action.activity.channelData.autosuggest && - ["google-city", "static", "repository"].includes( + ["google-places-city", "static", "repository"].includes( action.activity.channelData.autosuggest.type ), autoSuggestType: