Merge pull request #318 from esteemapp/declinedPayout

created declined payout
This commit is contained in:
Feruz M 2019-01-02 22:57:22 +02:00 committed by GitHub
commit 30c95e20fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 13 deletions

View File

@ -46,6 +46,7 @@ class UpvoteContainer extends PureComponent {
pinCode,
} = this.props;
let author;
let isDecinedPayout;
let isVoted;
let permlink;
let totalPayout;
@ -54,6 +55,7 @@ class UpvoteContainer extends PureComponent {
({ author } = content);
isVoted = content.is_voted;
totalPayout = content.total_payout;
isDecinedPayout = content.is_declined_payout;
({ permlink } = content);
}
@ -63,13 +65,14 @@ class UpvoteContainer extends PureComponent {
currentAccount={currentAccount}
fetchPost={fetchPost}
handleSetUpvotePercent={this._setUpvotePercent}
isDecinedPayout={isDecinedPayout}
isLoggedIn={isLoggedIn}
isShowPayoutValue={isShowPayoutValue}
isVoted={isVoted}
totalPayout={totalPayout}
permlink={permlink}
upvotePercent={upvotePercent}
pinCode={pinCode}
totalPayout={totalPayout}
upvotePercent={upvotePercent}
/>
);
}

View File

@ -64,4 +64,8 @@ export default EStyleSheet.create({
color: '$primaryDarkGray',
marginLeft: 8,
},
declinedPayout: {
textDecorationLine: 'line-through',
textDecorationStyle: 'solid',
},
});

View File

@ -120,7 +120,7 @@ class UpvoteView extends Component {
};
render() {
const { isLoggedIn, isShowPayoutValue, totalPayout } = this.props;
const { isDecinedPayout, isLoggedIn, isShowPayoutValue, totalPayout } = this.props;
const {
isVoting, amount, sliderValue, isVoted,
} = this.state;
@ -168,7 +168,7 @@ class UpvoteView extends Component {
/>
)}
{isShowPayoutValue && totalPayout && (
<Text style={styles.payoutValue}>{`$${totalPayout}`}</Text>
<Text style={[styles.payoutValue, isDecinedPayout && styles.declinedPayout]}>{`$${totalPayout}`}</Text>
)}
</Fragment>
</TouchableOpacity>

View File

@ -4,7 +4,8 @@ import { getPostSummary } from './formatter';
import { getReputation } from './reputation';
import { getTimeFromNow } from './time';
export const parsePosts = (posts, currentUserName, isSummary) => (!posts ? null : posts.map(post => parsePost(post, currentUserName, isSummary)));
export const parsePosts = (posts, currentUserName, isSummary) =>
!posts ? null : posts.map(post => parsePost(post, currentUserName, isSummary));
export const parsePost = (post, currentUserName, isSummary = false) => {
if (!post) {
@ -22,6 +23,7 @@ export const parsePost = (post, currentUserName, isSummary = false) => {
_post.body = markDown2Html(post.body);
_post.summary = getPostSummary(post.body, 150);
_post.is_declined_payout = Number(parseFloat(post.max_accepted_payout)) === 0;
if (currentUserName) {
_post.is_voted = isVoted(_post.active_votes, currentUserName);
@ -29,9 +31,10 @@ export const parsePost = (post, currentUserName, isSummary = false) => {
_post.is_voted = false;
}
const totalPayout = parseFloat(_post.pending_payout_value)
+ parseFloat(_post.total_payout_value)
+ parseFloat(_post.curator_payout_value);
const totalPayout =
parseFloat(_post.pending_payout_value) +
parseFloat(_post.total_payout_value) +
parseFloat(_post.curator_payout_value);
_post.total_payout = totalPayout.toFixed(3);
@ -40,7 +43,8 @@ export const parsePost = (post, currentUserName, isSummary = false) => {
if (_post.active_votes && _post.active_votes.length > 0) {
for (const i in _post.active_votes) {
_post.vote_perecent = post.active_votes[i].voter === currentUserName ? post.active_votes[i].percent : null;
_post.vote_perecent =
post.active_votes[i].voter === currentUserName ? post.active_votes[i].percent : null;
_post.active_votes[i].value = (post.active_votes[i].rshares * ratio).toFixed(2);
_post.active_votes[i].reputation = getReputation(post.active_votes[i].reputation);
_post.active_votes[i].percent = post.active_votes[i].percent / 100;
@ -55,7 +59,8 @@ export const parsePost = (post, currentUserName, isSummary = false) => {
return _post;
};
const isVoted = (activeVotes, currentUserName) => activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
const isVoted = (activeVotes, currentUserName) =>
activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
const postImage = (metaData, body) => {
const markdownImageRegex = /!\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\)/g;
@ -84,7 +89,7 @@ const postImage = (metaData, body) => {
return '';
};
export const protocolUrl2Obj = (url) => {
export const protocolUrl2Obj = url => {
let urlPart = url.split('://')[1];
// remove last char if /
@ -120,8 +125,8 @@ export const protocolUrl2Obj = (url) => {
}
};
export const parseComments = (comments) => {
comments.map((comment) => {
export const parseComments = comments => {
comments.map(comment => {
comment.pending_payout_value = parseFloat(comment.pending_payout_value).toFixed(3);
comment.created = getTimeFromNow(comment.created);
comment.vote_count = comment.active_votes.length;