Skip to content

Commit

Permalink
Merge pull request #2757 from ecency/nt/wave-hide
Browse files Browse the repository at this point in the history
hide downvoted content with reveal button
  • Loading branch information
feruzm authored Sep 19, 2023
2 parents fc3a02c + dcd9ed8 commit da8e650
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
18 changes: 10 additions & 8 deletions src/components/comment/view/commentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const CommentView = ({

const _handleOnReplyPress = () => {
if (isLoggedIn) {
dispatch(showReplyModal({mode:'comment', parentPost:comment}));
dispatch(showReplyModal({ mode: 'comment', parentPost: comment }));
} else {
console.log('Not LoggedIn');
}
Expand All @@ -97,21 +97,23 @@ const CommentView = ({
);

const _renderComment = () => {

const _hideContent = isMuted || comment.author_reputation < 25 || comment.net_rshares < 0;

return (
<View style={[{ marginLeft: 2, marginTop: -6 }]}>
<CommentBody
body={comment.body}
key={`key-${comment.permlink}`}
hideContent={_hideContent}
commentDepth={_depth}
reputation={comment.author_reputation}
handleOnContentPress={_handleOnContentPress}
handleOnUserPress={handleOnUserPress}
handleOnLongPress={() => handleOnLongPress(comment)}
handleLinkPress={handleLinkPress}
handleImagePress={handleImagePress}
handleVideoPress={handleVideoPress}
handleYoutubePress={handleYoutubePress}
body={comment.body}
key={`key-${comment.permlink}`}
isMuted={isMuted}
/>

<Fragment>
Expand Down Expand Up @@ -216,9 +218,9 @@ const CommentView = ({
const customContainerStyle =
_depth > 1
? {
paddingLeft: (_depth - 2) * 44,
backgroundColor: EStyleSheet.value('$primaryLightBackground'),
}
paddingLeft: (_depth - 2) * 44,
backgroundColor: EStyleSheet.value('$primaryLightBackground'),
}
: null;

return (
Expand Down
23 changes: 18 additions & 5 deletions src/components/postElements/body/view/commentBodyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,24 @@ import getWindowDimensions from '../../../../utils/getWindowDimensions';

const WIDTH = getWindowDimensions().width;

interface CommentBodyProps {
body: string;
commentDepth: number;
hideContent: boolean;
handleOnContentPress: () => void;
handleOnUserPress: () => void;
handleOnPostPress: () => void;
handleOnLongPress: () => void;
handleVideoPress: () => void;
handleYoutubePress: () => void;
handleImagePress: () => void;
handleLinkPress: () => void;
}

const CommentBody = ({
body,
commentDepth,
hideContent,
handleOnContentPress,
handleOnUserPress,
handleOnPostPress,
Expand All @@ -32,15 +48,12 @@ const CommentBody = ({
handleYoutubePress,
handleImagePress,
handleLinkPress,
commentDepth,
reputation = 25,
isMuted,
}) => {
}: CommentBodyProps) => {
const _contentWidth = WIDTH - (40 + 28 + (commentDepth > 2 ? 44 : 0));

const dispatch = useAppDispatch();

const [revealComment, setRevealComment] = useState(reputation > 0 && !isMuted);
const [revealComment, setRevealComment] = useState(!hideContent);

const intl = useIntl();

Expand Down
2 changes: 1 addition & 1 deletion src/config/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@
},
"comments": {
"title": "Comments",
"reveal_comment": "Reveal comment",
"reveal_comment": "Reveal Content",
"read_more": "Read more comments",
"more_replies": "replies",
"no_comments":"Be the first to respond..."
Expand Down
3 changes: 2 additions & 1 deletion src/utils/postParser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ export const injectVoteCache = (post, voteCache) => {
const _oldReward = calculateVoteReward(_vote.rshares, post);

//update total payout
post.total_payout += voteCache.amount - _oldReward;
const _voteAmount = voteCache.amount * (voteCache.isDownvote ? -1 : 1);
post.total_payout += _voteAmount - _oldReward

//update vote entry
_vote.rshares = voteCache.rshares
Expand Down

0 comments on commit da8e650

Please sign in to comment.