Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 8 additions & 25 deletions package/src/components/Message/MessageSimple/MessageBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,8 @@ export const SwipableMessageBubble = React.memo(
'shouldRenderSwipeableWrapper' | 'messageSwipeToReplyHitSlop'
> & { onSwipe: () => void },
) => {
const {
MessageSwipeContent,
shouldRenderSwipeableWrapper,
messageSwipeToReplyHitSlop,
onSwipe,
...messageBubbleProps
} = props;
const { MessageSwipeContent, messageSwipeToReplyHitSlop, onSwipe, ...messageBubbleProps } =
props;

const {
theme: {
Expand All @@ -96,9 +91,7 @@ export const SwipableMessageBubble = React.memo(
const translateX = useSharedValue(0);
const touchStart = useSharedValue<{ x: number; y: number } | null>(null);
const isSwiping = useSharedValue<boolean>(false);
const [shouldRenderAnimatedWrapper, setShouldRenderAnimatedWrapper] = useState<boolean>(
shouldRenderSwipeableWrapper,
);
const [shouldRenderAnimatedWrapper, setShouldRenderAnimatedWrapper] = useState<boolean>(false);

const SWIPABLE_THRESHOLD = 25;
const MINIMUM_DISTANCE = 8;
Expand Down Expand Up @@ -134,10 +127,10 @@ export const SwipableMessageBubble = React.memo(
// Only activate if there's significant horizontal movement
if (isHorizontalPanning && hasMinimumDistance) {
state.activate();
isSwiping.value = true;
if (!shouldRenderSwipeableWrapper) {
runOnJS(setShouldRenderAnimatedWrapper)(isSwiping.value);
if (!isSwiping.value) {
runOnJS(setShouldRenderAnimatedWrapper)(true);
}
isSwiping.value = true;
} else if (hasMinimumDistance) {
// If there's significant movement but not horizontal, fail the gesture
state.fail();
Expand Down Expand Up @@ -168,21 +161,11 @@ export const SwipableMessageBubble = React.memo(
stiffness: 1,
},
() => {
if (!shouldRenderSwipeableWrapper) {
runOnJS(setShouldRenderAnimatedWrapper)(isSwiping.value);
}
runOnJS(setShouldRenderAnimatedWrapper)(false);
},
);
}),
[
messageSwipeToReplyHitSlop,
touchStart,
isSwiping,
shouldRenderSwipeableWrapper,
translateX,
onSwipe,
triggerHaptic,
],
[messageSwipeToReplyHitSlop, touchStart, isSwiping, translateX, onSwipe, triggerHaptic],
);

const swipeContentAnimatedStyle = useAnimatedStyle(
Expand Down
Loading