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