Prevent post delete swipe from intercepting media gestures
This commit is contained in:
@@ -26,6 +26,7 @@ let Post = (props) => {
|
||||
let [bookmarked, changeBookmarked] = useState(post.bookmarks && post.bookmarks.includes(viewer._id));
|
||||
const isOwner = String(post.profileid || '') === String(viewer?._id || '');
|
||||
const swipeX = useRef(new Animated.Value(0)).current;
|
||||
const mediaGestureActiveRef = useRef(false);
|
||||
const SWIPE_WIDTH = 86;
|
||||
let toProfileText = post.toProfile && post.toProfile !== post.profileid ?
|
||||
<ProfilePhotoCircle profileid={post.toProfile} small={true} /> : undefined;
|
||||
@@ -118,6 +119,7 @@ let Post = (props) => {
|
||||
const panResponder = useMemo(() => PanResponder.create({
|
||||
onMoveShouldSetPanResponder: (_, gestureState) =>
|
||||
isOwner &&
|
||||
!mediaGestureActiveRef.current &&
|
||||
Math.abs(gestureState.dx) > 8 &&
|
||||
Math.abs(gestureState.dx) > Math.abs(gestureState.dy),
|
||||
onPanResponderMove: (_, gestureState) => {
|
||||
@@ -171,13 +173,59 @@ let Post = (props) => {
|
||||
</ParsedText>
|
||||
</Pressable>
|
||||
|
||||
<View
|
||||
onStartShouldSetResponderCapture={() => {
|
||||
mediaGestureActiveRef.current = true;
|
||||
return false;
|
||||
}}
|
||||
onMoveShouldSetResponderCapture={() => {
|
||||
mediaGestureActiveRef.current = true;
|
||||
return false;
|
||||
}}
|
||||
onResponderRelease={() => {
|
||||
mediaGestureActiveRef.current = false;
|
||||
}}
|
||||
onResponderTerminate={() => {
|
||||
mediaGestureActiveRef.current = false;
|
||||
}}
|
||||
onTouchEnd={() => {
|
||||
mediaGestureActiveRef.current = false;
|
||||
}}
|
||||
onTouchCancel={() => {
|
||||
mediaGestureActiveRef.current = false;
|
||||
}}
|
||||
>
|
||||
<Media content={post.content} postId={post._id} post={post} style={{ paddingTop: 2 }} />
|
||||
</View>
|
||||
</View> :
|
||||
<View>
|
||||
<Chip icon="new-releases" style={{ width: 100 }} >{i18n.t("message.news")}</Chip>
|
||||
<Text style={{ fontSize: 18 }}>{cleanContent}</Text>
|
||||
<View
|
||||
onStartShouldSetResponderCapture={() => {
|
||||
mediaGestureActiveRef.current = true;
|
||||
return false;
|
||||
}}
|
||||
onMoveShouldSetResponderCapture={() => {
|
||||
mediaGestureActiveRef.current = true;
|
||||
return false;
|
||||
}}
|
||||
onResponderRelease={() => {
|
||||
mediaGestureActiveRef.current = false;
|
||||
}}
|
||||
onResponderTerminate={() => {
|
||||
mediaGestureActiveRef.current = false;
|
||||
}}
|
||||
onTouchEnd={() => {
|
||||
mediaGestureActiveRef.current = false;
|
||||
}}
|
||||
onTouchCancel={() => {
|
||||
mediaGestureActiveRef.current = false;
|
||||
}}
|
||||
>
|
||||
<Media content={post.content} />
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
</Card.Content>
|
||||
<Card.Actions style={{ flexDirection: "row", flow: 4, fontSize: 16, marginLeft: 36, marginTop: -10 }}>
|
||||
|
||||
Reference in New Issue
Block a user