From 49c92cfa7b48ba42f01fb4643acfab3a8162803c Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Wed, 30 Mar 2022 17:55:57 -0400 Subject: [PATCH] [FIX] `AttachedActions`'s button (#3989) * fix: `AttachedActions`'s button * fix: text color * update: `Message.storyshot` --- app/containers/message/Attachments.tsx | 26 ++++++++++++++++--- .../stories/__snapshots__/Message.storyshot | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/containers/message/Attachments.tsx b/app/containers/message/Attachments.tsx index 6c6a6cb6a..1203c55af 100644 --- a/app/containers/message/Attachments.tsx +++ b/app/containers/message/Attachments.tsx @@ -13,6 +13,15 @@ import MessageContext from './Context'; import { useTheme } from '../../theme'; import { IAttachment } from '../../definitions'; import CollapsibleQuote from './Components/CollapsibleQuote'; +import openLink from '../../utils/openLink'; +import { themes } from '../../constants/colors'; + +export type TElement = { + type: string; + msg?: string; + url?: string; + text: string; +}; const AttachedActions = ({ attachment }: IMessageAttachedActions) => { if (!attachment.actions) { @@ -21,15 +30,26 @@ const AttachedActions = ({ attachment }: IMessageAttachedActions) => { const { onAnswerButtonPress } = useContext(MessageContext); const { theme } = useTheme(); - const attachedButtons = attachment.actions.map((element: { type: string; msg: string; text: string }) => { + const attachedButtons = attachment.actions.map((element: TElement) => { + const onPress = () => { + if (element.msg) { + onAnswerButtonPress(element.msg); + } + + if (element.url) { + openLink(element.url); + } + }; + if (element.type === 'button') { - return