Skip to content

Commit

Permalink
Merge pull request #612 from ephemeraHQ/ar/context-crash
Browse files Browse the repository at this point in the history
fix: Context Menu Crash
  • Loading branch information
alexrisch authored Aug 29, 2024
2 parents 9614ed3 + 778fa22 commit 7e549bc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions components/Chat/Message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ type Props = {
isFrame: boolean;
};

// On iOS, the native context menu view handles the long press, but could potentially trigger the onPress event
// So we have to set a noop on long press on iOS so it doens't also trigger the onPress event
const platformTouchableLongPressDelay = Platform.select({
ios: 100,
default: undefined,
});

const noop = () => {};

const platformTouchableOnLongPress = Platform.select({
ios: noop,
default: undefined,
});

const MessageSender = ({ message }: { message: MessageToDisplay }) => {
const address = useInboxIdStore(
(s) => s.byInboxId[message.senderAddress]?.[0] ?? message.senderAddress
Expand Down Expand Up @@ -327,6 +341,8 @@ function ChatMessage({ message, colorScheme, isGroup, isFrame }: Props) {
styles.innerBubble,
message.fromMe ? styles.innerBubbleMe : undefined,
]}
delayLongPress={platformTouchableLongPressDelay}
onLongPress={platformTouchableOnLongPress}
delayPressIn={isDesktop ? 0 : 75}
onPress={() => {
converseEventEmitter.emit("scrollChatToMessage", {
Expand Down Expand Up @@ -395,6 +411,8 @@ function ChatMessage({ message, colorScheme, isGroup, isFrame }: Props) {
{isFrame && (
<TouchableOpacity
onPress={() => handleUrlPress(message.content)}
delayLongPress={platformTouchableLongPressDelay}
onLongPress={platformTouchableOnLongPress}
>
<Text style={styles.linkToFrame}>
{getUrlToRender(message.content)}
Expand Down

0 comments on commit 7e549bc

Please sign in to comment.