hide low rep comments, intl

This commit is contained in:
feruz 2020-01-22 06:11:48 +02:00
parent 239d57b3f6
commit b60cd7615a
6 changed files with 54 additions and 83 deletions

View File

@ -65,6 +65,7 @@ const CommentView = ({
<View style={[{ marginLeft: 34 }, styles.bodyWrapper]}> <View style={[{ marginLeft: 34 }, styles.bodyWrapper]}>
<CommentBody <CommentBody
commentDepth={comment.depth} commentDepth={comment.depth}
reputation={comment.author_reputation}
handleOnUserPress={handleOnUserPress} handleOnUserPress={handleOnUserPress}
body={comment.body} body={comment.body}
created={comment.created} created={comment.created}
@ -147,7 +148,11 @@ const CommentView = ({
iconStyle={styles.iconStyle} iconStyle={styles.iconStyle}
iconSize={16} iconSize={16}
onPress={() => _showSubCommentsToggle()} onPress={() => _showSubCommentsToggle()}
text={!isPressedShowButton ? `${comment.children} more replies` : ''} text={
!isPressedShowButton
? `${comment.children} ${intl.formatMessage({ id: 'comments.more_replies' })}`
: ''
}
/> />
</View> </View>
)} )}

View File

@ -72,7 +72,7 @@ const CommentsView = ({
style={styles.moreRepliesButtonWrapper} style={styles.moreRepliesButtonWrapper}
textStyle={styles.moreRepliesText} textStyle={styles.moreRepliesText}
onPress={() => _readMoreComments()} onPress={() => _readMoreComments()}
text="Read more comments" text={intl.formatMessage({ id: 'comments.read_more' })}
/> />
); );
} }

View File

@ -16,7 +16,10 @@ import { default as ROUTES } from '../../../../constants/routeNames';
import { CommentPlaceHolder } from '../../../basicUIElements'; import { CommentPlaceHolder } from '../../../basicUIElements';
import { customCommentScript } from './config'; import { customCommentScript } from './config';
import { TextButton } from '../../..';
// Styles // Styles
import styles from './postBodyStyles';
const WIDTH = Dimensions.get('window').width; const WIDTH = Dimensions.get('window').width;
@ -27,11 +30,16 @@ const CommentBody = ({
handleOnPostPress, handleOnPostPress,
created, created,
commentDepth, commentDepth,
reputation,
}) => { }) => {
const [isImageModalOpen, setIsImageModalOpen] = useState(false); const [isImageModalOpen, setIsImageModalOpen] = useState(false);
const [postImages, setPostImages] = useState([]); const [postImages, setPostImages] = useState([]);
const [revealComment, setRevealComment] = useState(reputation > 0);
const intl = useIntl(); const intl = useIntl();
const _showLowComment = () => {
setRevealComment(true);
};
//new renderer functions //new renderer functions
const __handleOnLinkPress = event => { const __handleOnLinkPress = event => {
if ((!event && !get(event, 'nativeEvent.data'), false)) { if ((!event && !get(event, 'nativeEvent.data'), false)) {
@ -347,21 +355,30 @@ const CommentBody = ({
}} }}
/> />
</Modal> </Modal>
<AutoHeightWebView {revealComment ? (
key={`akey-${created.toString()}`} <AutoHeightWebView
source={{ html }} key={`akey-${created.toString()}`}
allowsFullscreenVideo={true} source={{ html }}
style={{ width: WIDTH - (32 + 34 * (commentDepth % 6)) }} allowsFullscreenVideo={true}
customStyle={customStyle} style={{ width: WIDTH - (32 + 34 * (commentDepth % 6)) }}
onMessage={__handleOnLinkPress} customStyle={customStyle}
customScript={customCommentScript} onMessage={__handleOnLinkPress}
renderLoading={() => <CommentPlaceHolder />} customScript={customCommentScript}
startInLoadingState={true} renderLoading={() => <CommentPlaceHolder />}
onShouldStartLoadWithRequest={false} startInLoadingState={true}
scrollEnabled={false} onShouldStartLoadWithRequest={false}
scalesPageToFit={false} scrollEnabled={false}
zoomable={false} scalesPageToFit={false}
/> zoomable={false}
/>
) : (
<TextButton
style={styles.revealButton}
textStyle={styles.revealText}
onPress={() => _showLowComment()}
text={intl.formatMessage({ id: 'comments.reveal_comment' })}
/>
)}
</Fragment> </Fragment>
); );
}; };

View File

@ -137,6 +137,7 @@ for (var i = 0; i < images.length; i++) {
} }
} }
document.addEventListener('touchstart', function(event) { document.addEventListener('touchstart', function(event) {
event.preventDefault();
var el = event.target; var el = event.target;
while (el.tagName !== 'A') { while (el.tagName !== 'A') {
if (!el.parentNode) { if (!el.parentNode) {
@ -228,7 +229,7 @@ document.addEventListener('touchstart', function(event) {
return false; return false;
} }
} }
}, { passive: false }); });
true; true;
`; `;

View File

@ -1,72 +1,17 @@
import EStyleSheet from 'react-native-extended-stylesheet'; import EStyleSheet from 'react-native-extended-stylesheet';
export default EStyleSheet.create({ export default EStyleSheet.create({
text: { revealButton: {
fontSize: 16, backgroundColor: '$iconColor',
color: '$primaryBlack', height: 22,
fontFamily: '$primaryFont',
},
container: {
paddingHorizontal: 0,
marginTop: 10,
},
a: {
color: '$primaryBlue',
fontFamily: '$primaryFont',
},
h4: {
fontSize: 15,
marginHorizontal: 10,
marginVertical: 5,
},
h1: {
fontSize: 30,
},
h2: {
fontSize: 25,
},
h3: {
fontSize: 20,
},
commentContainer: {
paddingHorizontal: 0,
right: 30,
marginTop: 10,
},
th: {
flex: 1,
justifyContent: 'center', justifyContent: 'center',
fontWeight: 'bold',
color: '$primaryBlack',
fontSize: 14,
padding: 5,
},
tr: {
backgroundColor: '$darkIconColor',
flexDirection: 'row',
},
td: {
borderWidth: 0.5,
borderColor: '$tableBorderColor',
flex: 1,
padding: 10,
backgroundColor: '$tableTrColor',
},
blockquote: {
borderLeftWidth: 5,
borderColor: '$darkIconColor',
paddingLeft: 5,
},
code: {
backgroundColor: '$darkIconColor',
fontFamily: '$editorFont',
},
center: {
textAlign: 'center',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', borderRadius: 20,
minWidth: 40,
maxWidth: 170,
}, },
img: { revealText: {
alignSelf: 'center', color: '$white',
fontSize: 14,
}, },
}); });

View File

@ -464,6 +464,9 @@
} }
}, },
"comments": { "comments": {
"title": "Comments" "title": "Comments",
"reveal_comment": "Reveal comment",
"read_more": "Read more comments",
"more_replies": "more replies"
} }
} }