From bb618f0bc41e7c12e2a597a8d09f5d339d70880d Mon Sep 17 00:00:00 2001 From: varodv <72568818+alvarodE@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:15:54 +0200 Subject: [PATCH 1/2] feat: Send spellchecked query to Backroom --- src/App.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/App.vue b/src/App.vue index 710204b7..e66bb741 100644 --- a/src/App.vue +++ b/src/App.vue @@ -61,7 +61,11 @@ @XOn(['SearchRequestChanged']) setWysiwygContext(payload: InternalSearchRequest | null): void { - window.wysiwyg?.setContext({ query: payload?.query }); + const { wysiwyg } = window; + if (wysiwyg) { + const query = this.$x.spellcheckedQuery! || payload?.query; + wysiwyg.setContext({ query }); + } } @XOn(['ParamsLoadedFromUrl']) From 58f584e71752f65a2696fd681b838942b9d98504 Mon Sep 17 00:00:00 2001 From: varodv <72568818+alvarodE@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:07:06 +0200 Subject: [PATCH 2/2] feat: changed approach to update spellcheck on Search response --- src/App.vue | 15 +++++++++------ src/main.ts | 7 ++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/App.vue b/src/App.vue index e66bb741..716f9236 100644 --- a/src/App.vue +++ b/src/App.vue @@ -22,7 +22,7 @@ import { QueryPreviewInfo } from '@empathyco/x-components/queries-preview'; import { UrlHandler } from '@empathyco/x-components/url'; import { SnippetConfigExtraParams } from '@empathyco/x-components/extra-params'; - import { InternalSearchRequest } from '@empathyco/x-components/search'; + import { InternalSearchRequest, InternalSearchResponse } from '@empathyco/x-components/search'; import { Component, Inject, Provide, Vue, Watch } from 'vue-property-decorator'; import { useDevice } from './composables/use-device.composable'; import currencies from './i18n/currencies'; @@ -60,11 +60,14 @@ } @XOn(['SearchRequestChanged']) - setWysiwygContext(payload: InternalSearchRequest | null): void { - const { wysiwyg } = window; - if (wysiwyg) { - const query = this.$x.spellcheckedQuery! || payload?.query; - wysiwyg.setContext({ query }); + onSearchRequestChanged(payload: InternalSearchRequest | null): void { + window.wysiwyg?.setContext({ query: payload?.query, spellcheckedQuery: undefined }); + } + + @XOn(['SearchResponseChanged']) + onSearchResponseChanged(payload: InternalSearchResponse): void { + if (payload.spellcheck) { + window.wysiwyg?.setContext({ spellcheckedQuery: payload.spellcheck }); } } diff --git a/src/main.ts b/src/main.ts index 9579c0cf..e0f2fa77 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,7 +11,12 @@ declare global { requestAuth: () => Promise; open: () => Promise; close: () => Promise; - setContext: (newContext: { query: string | undefined }) => void; + setContext: ( + newContext: Partial<{ + query: string | undefined; + spellcheckedQuery: string | undefined; + }> + ) => void; }; } }