diff --git a/src/common/ActionButtons/ActionButton.tsx b/src/common/ActionButtons/ActionButton.tsx index cfbb4b7..7410ade 100644 --- a/src/common/ActionButtons/ActionButton.tsx +++ b/src/common/ActionButtons/ActionButton.tsx @@ -41,8 +41,14 @@ const ActionButton: FC = props => { } = props; const buttonType = - "type" in button ? button.type : "content_type" in button ? button.content_type : "contentType" in button ? (button as any).contentType : null; - + "type" in button + ? button.type + : "content_type" in button + ? button.content_type + : "contentType" in button + ? (button as any).contentType + : null; + if (!buttonType) return null; const buttonLabel = getWebchatButtonLabel(button) || ""; diff --git a/src/common/ActionButtons/ActionButtons.tsx b/src/common/ActionButtons/ActionButtons.tsx index 0f70d55..90d98b0 100644 --- a/src/common/ActionButtons/ActionButtons.tsx +++ b/src/common/ActionButtons/ActionButtons.tsx @@ -10,7 +10,7 @@ import { useRandomId } from "src/messages/hooks"; type buttonPayloadCompatibility = { contentType?: string; -} +}; export interface ActionButtonsProps { className?: string; diff --git a/src/matcher.ts b/src/matcher.ts index 5ee28a9..d02fbaa 100644 --- a/src/matcher.ts +++ b/src/matcher.ts @@ -60,13 +60,13 @@ const defaultConfig: MatchConfig[] = [ const isTextWithButtons = (channelConfig?.message?.attachment as IWebchatTemplateAttachment)?.payload ?.template_type === "button"; - - const hasMessengerText = channelConfig?.message?.text; + + const hasMessengerText = channelConfig?.message?.text; const isDefaultPreviewEnabled = config?.settings?.widgetSettings?.enableDefaultPreview; const hasDefaultPreview = message?.data?._cognigy?._defaultPreview; // DefaultPreview chooses text over _webchat / _facebook content - const shouldSkip = isDefaultPreviewEnabled && !hasDefaultPreview && message.text + const shouldSkip = isDefaultPreviewEnabled && !hasDefaultPreview && message.text; return !shouldSkip && (isQuickReplies || isTextWithButtons || hasMessengerText); }, diff --git a/test/demo.tsx b/test/demo.tsx index 1304aff..f6b0633 100644 --- a/test/demo.tsx +++ b/test/demo.tsx @@ -35,7 +35,7 @@ const action: MessageSender = (text, data) => alert("Text: " + JSON.stringify(text, null, 2) + " Data: " + JSON.stringify(data, null, 2)); type DeepPartial = { - [P in keyof T]?: T[P] extends object ? DeepPartial : T[P]; + [P in keyof T]?: T[P] extends object ? DeepPartial : T[P]; }; type TScreen = { @@ -74,10 +74,10 @@ const screens: TScreen[] = [ config: { settings: { widgetSettings: { - enableDefaultPreview: true - } - } - } + enableDefaultPreview: true, + }, + }, + }, }, { message: { @@ -85,25 +85,25 @@ const screens: TScreen[] = [ _cognigy: { _webchat: { message: { - text: "RENDER WRONG" - } + text: "RENDER WRONG", + }, }, _defaultPreview: { message: { - text: "RENDER OK" - } + text: "RENDER OK", + }, }, - } - } + }, + }, }, config: { settings: { widgetSettings: { - enableDefaultPreview: true - } - } - } - } + enableDefaultPreview: true, + }, + }, + }, + }, ], }, {