From 35ff90edb0647e210fd41d279baef03645c483ab Mon Sep 17 00:00:00 2001 From: Alex Risch Date: Tue, 29 Oct 2024 09:58:15 -0400 Subject: [PATCH] fix: Set is Frame when ending with slash Added handling to clean url Updated to use util function --- components/Chat/Message/Message.tsx | 9 ++++++++- utils/frames.ts | 14 ++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/components/Chat/Message/Message.tsx b/components/Chat/Message/Message.tsx index 95c39fb8d..ad53e2785 100644 --- a/components/Chat/Message/Message.tsx +++ b/components/Chat/Message/Message.tsx @@ -7,6 +7,7 @@ import { textSecondaryColor, } from "@styles/colors"; import { AvatarSizes } from "@styles/sizes"; +import { isFrameMessage } from "@utils/frames"; import * as Haptics from "expo-haptics"; import React, { ReactNode, useCallback, useMemo, useRef } from "react"; import { @@ -167,7 +168,13 @@ const ChatMessage = ({ ); // The content is completely a frame so a larger full width frame will be shown const isFrame = useFramesStore( - useShallow((s) => !!s.frames[message.content.toLowerCase().trim()]) + useShallow((s) => + isFrameMessage( + isContentType("text", message.contentType), + message.content, + s.frames + ) + ) ); // Reanimated shared values for time and date-time animations diff --git a/utils/frames.ts b/utils/frames.ts index 483268275..bf9ea1966 100644 --- a/utils/frames.ts +++ b/utils/frames.ts @@ -271,16 +271,18 @@ export const handleTxAction = async ( }; export const isFrameMessage = ( - message: MessageToDisplay, + messageIsText: boolean, + messageContent: string, framesStore: { [frameUrl: string]: FrameWithType; } ): boolean => { - return ( - isContentType("text", message.contentType) && - !!message.converseMetadata?.frames?.[0] && - !!framesStore[message.converseMetadata.frames[0].toLowerCase().trim()] - ); + if (!messageIsText) return false; + const content = messageContent.toLowerCase().trim(); + const sanitizedContent = content.endsWith("/") + ? content.slice(0, -1) + : content; + return !!framesStore[sanitizedContent]; }; export const messageHasFrames = (