mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-23 05:13:04 +03:00
fixed comment image/link clicks and long press 1.5s
This commit is contained in:
parent
945d669abd
commit
2a7a1021fd
@ -1,5 +1,5 @@
|
|||||||
import React, { Fragment, useState, useRef } from 'react';
|
import React, { Fragment, useState, useRef } from 'react';
|
||||||
import { View, TouchableWithoutFeedback } from 'react-native';
|
import { View } from 'react-native';
|
||||||
import ActionSheet from 'react-native-actionsheet';
|
import ActionSheet from 'react-native-actionsheet';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
@ -50,7 +50,7 @@ const CommentView = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableWithoutFeedback onLongPress={handleOnLongPress} delayLongPress={2000}>
|
<Fragment>
|
||||||
<View style={styles.commentContainer}>
|
<View style={styles.commentContainer}>
|
||||||
<PostHeaderDescription
|
<PostHeaderDescription
|
||||||
key={comment.permlink}
|
key={comment.permlink}
|
||||||
@ -67,6 +67,7 @@ const CommentView = ({
|
|||||||
commentDepth={comment.depth}
|
commentDepth={comment.depth}
|
||||||
reputation={comment.author_reputation}
|
reputation={comment.author_reputation}
|
||||||
handleOnUserPress={handleOnUserPress}
|
handleOnUserPress={handleOnUserPress}
|
||||||
|
handleOnLongPress={handleOnLongPress}
|
||||||
body={comment.body}
|
body={comment.body}
|
||||||
created={comment.created}
|
created={comment.created}
|
||||||
key={`key-${comment.permlink}`}
|
key={`key-${comment.permlink}`}
|
||||||
@ -176,7 +177,7 @@ const CommentView = ({
|
|||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</TouchableWithoutFeedback>
|
</Fragment>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ const CommentBody = ({
|
|||||||
textSelectable = true,
|
textSelectable = true,
|
||||||
handleOnUserPress,
|
handleOnUserPress,
|
||||||
handleOnPostPress,
|
handleOnPostPress,
|
||||||
|
handleOnLongPress,
|
||||||
created,
|
created,
|
||||||
commentDepth,
|
commentDepth,
|
||||||
reputation,
|
reputation,
|
||||||
@ -84,6 +85,9 @@ const CommentBody = ({
|
|||||||
setSelectedLink(href);
|
setSelectedLink(href);
|
||||||
actionLink.current.show();
|
actionLink.current.show();
|
||||||
break;
|
break;
|
||||||
|
case 'longpress':
|
||||||
|
handleOnLongPress();
|
||||||
|
break;
|
||||||
case 'markdown-author-link':
|
case 'markdown-author-link':
|
||||||
if (!handleOnUserPress) {
|
if (!handleOnUserPress) {
|
||||||
__handleOnUserPress(author);
|
__handleOnUserPress(author);
|
||||||
|
@ -118,6 +118,8 @@ true;
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const customCommentScript = `
|
const customCommentScript = `
|
||||||
|
var longpress = 1500;
|
||||||
|
var delay;
|
||||||
var images = document.getElementsByTagName("IMG");
|
var images = document.getElementsByTagName("IMG");
|
||||||
var imageUrls = [];
|
var imageUrls = [];
|
||||||
for (var k = 0; k < images.length; k++) {
|
for (var k = 0; k < images.length; k++) {
|
||||||
@ -138,6 +140,22 @@ for (var i = 0; i < images.length; i++) {
|
|||||||
images[i].setAttribute("onclick", message);
|
images[i].setAttribute("onclick", message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
document.addEventListener('mousedown', function(event) {
|
||||||
|
delay = setTimeout(check, longpress);
|
||||||
|
function check() {
|
||||||
|
var result = {
|
||||||
|
type: 'longpress',
|
||||||
|
};
|
||||||
|
window.ReactNativeWebView.postMessage(JSON.stringify(result));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
document.addEventListener('mouseup', function (e) {
|
||||||
|
clearTimeout(delay);
|
||||||
|
});
|
||||||
|
document.addEventListener('mouseout', function (e) {
|
||||||
|
clearTimeout(delay);
|
||||||
|
});
|
||||||
document.addEventListener('click', function(event) {
|
document.addEventListener('click', function(event) {
|
||||||
var el = event.target;
|
var el = event.target;
|
||||||
while (el.tagName !== 'A') {
|
while (el.tagName !== 'A') {
|
||||||
|
Loading…
Reference in New Issue
Block a user