Skip to content

Commit

Permalink
fix: Set is Frame when ending with slash
Browse files Browse the repository at this point in the history
Added handling to clean url
Updated to use util function
  • Loading branch information
alexrisch committed Oct 29, 2024
1 parent 92d51a4 commit 35ff90e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 8 additions & 1 deletion components/Chat/Message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions utils/frames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down

0 comments on commit 35ff90e

Please sign in to comment.