From 5bc785e593d87197bb55f446465856d8a18e1c76 Mon Sep 17 00:00:00 2001 From: "jan.badura" Date: Thu, 21 Nov 2024 14:00:36 +0100 Subject: [PATCH 1/2] feat: FBOT-2494 new naming for autosuggest --- src/Shell.tsx | 16 ++++++---------- src/Store.ts | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Shell.tsx b/src/Shell.tsx index 98e632473a..99da4193a4 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 === "autosuggest-google-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) + if(this.props.autoSuggestType === "autosuggest-repository") { + 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..3d7df34a32 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( + ["autosuggest-google-city", "static", "autosuggest-repository"].includes( action.activity.channelData.autosuggest.type ), autoSuggestType: From e699a6699de3d87785f926942241491c1343a6ff Mon Sep 17 00:00:00 2001 From: "jan.badura" Date: Wed, 4 Dec 2024 21:18:04 +0100 Subject: [PATCH 2/2] fix: naming --- src/Shell.tsx | 4 ++-- src/Store.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Shell.tsx b/src/Shell.tsx index 99da4193a4..ec38b0d052 100644 --- a/src/Shell.tsx +++ b/src/Shell.tsx @@ -109,10 +109,10 @@ class ShellContainer extends React.Component implements ShellFunct }, 500); private autoSuggestOnKeyUp = (e: React.KeyboardEvent) => { - if (this.props.autoSuggestType === "autosuggest-google-city") { + if (this.props.autoSuggestType === "google-places-city") { this.debounceCall(e.currentTarget.value, this.props.autoSuggestType, this.props.autoSuggestCountry); } - if(this.props.autoSuggestType === "autosuggest-repository") { + if(this.props.autoSuggestType === "repository") { 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 3d7df34a32..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 && - ["autosuggest-google-city", "static", "autosuggest-repository"].includes( + ["google-places-city", "static", "repository"].includes( action.activity.channelData.autosuggest.type ), autoSuggestType: