mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-23 05:13:04 +03:00
Conflict
This commit is contained in:
commit
997bd99527
Binary file not shown.
@ -5,7 +5,6 @@ import { injectIntl } from 'react-intl';
|
||||
import get from 'lodash/get';
|
||||
|
||||
import { getComments, deleteComment } from '../../../providers/steem/dsteem';
|
||||
|
||||
// Services and Actions
|
||||
import { writeToClipboard } from '../../../utils/clipboard';
|
||||
import { toastNotification } from '../../../redux/actions/uiAction';
|
||||
@ -44,8 +43,8 @@ class CommentsContainer extends Component {
|
||||
this._getComments();
|
||||
}
|
||||
|
||||
if (selectedFilter !== nextProps.selectedFilter && nextProps.selectedFilter) {
|
||||
const shortedComments = this._shortComments(nextProps.selectedFilter);
|
||||
if (selectedFilter !== get(nextProps, 'selectedFilter') && get(nextProps, 'selectedFilter')) {
|
||||
const shortedComments = this._shortComments(get(nextProps, 'selectedFilter'));
|
||||
this.setState({ comments: shortedComments });
|
||||
}
|
||||
}
|
||||
@ -56,9 +55,9 @@ class CommentsContainer extends Component {
|
||||
const { comments: parent } = this.state;
|
||||
|
||||
const allPayout = c =>
|
||||
parseFloat(c.pending_payout_value.split(' ')[0]) +
|
||||
parseFloat(c.total_payout_value.split(' ')[0]) +
|
||||
parseFloat(c.curator_payout_value.split(' ')[0]);
|
||||
parseFloat(get(c, 'pending_payout_value').split(' ')[0]) +
|
||||
parseFloat(get(c, 'total_payout_value').split(' ')[0]) +
|
||||
parseFloat(get(c, 'curator_payout_value').split(' ')[0]);
|
||||
|
||||
const absNegative = a => a.net_rshares < 0;
|
||||
|
||||
@ -81,8 +80,8 @@ class CommentsContainer extends Component {
|
||||
return 0;
|
||||
},
|
||||
REPUTATION: (a, b) => {
|
||||
const keyA = a.author_reputation;
|
||||
const keyB = b.author_reputation;
|
||||
const keyA = get(a, 'author_reputation');
|
||||
const keyB = get(b, 'author_reputation');
|
||||
|
||||
if (keyA > keyB) return -1;
|
||||
if (keyA < keyB) return 1;
|
||||
@ -107,8 +106,8 @@ class CommentsContainer extends Component {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const keyA = Date.parse(a.created);
|
||||
const keyB = Date.parse(b.created);
|
||||
const keyA = Date.parse(get(a, 'created'));
|
||||
const keyB = Date.parse(get(b, 'created'));
|
||||
|
||||
if (keyA > keyB) return -1;
|
||||
if (keyA < keyB) return 1;
|
||||
@ -122,14 +121,20 @@ class CommentsContainer extends Component {
|
||||
return parent;
|
||||
};
|
||||
|
||||
_getComments = () => {
|
||||
const { author, permlink } = this.props;
|
||||
_getComments = async () => {
|
||||
const {
|
||||
author,
|
||||
permlink,
|
||||
currentAccount: { name },
|
||||
} = this.props;
|
||||
|
||||
getComments(author, permlink).then(comments => {
|
||||
this.setState({
|
||||
comments,
|
||||
});
|
||||
});
|
||||
await getComments(author, permlink, name)
|
||||
.then(comments => {
|
||||
this.setState({
|
||||
comments,
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
_handleOnReplyPress = item => {
|
||||
|
@ -67,7 +67,7 @@ class CommentsView extends PureComponent {
|
||||
mainAuthor={mainAuthor}
|
||||
avatarSize={avatarSize}
|
||||
comment={item}
|
||||
commentCount={commentCount || item.children}
|
||||
commentCount={commentCount || get(item.children)}
|
||||
commentNumber={commentNumber}
|
||||
handleDeleteComment={handleDeleteComment}
|
||||
currentAccountUsername={currentAccountUsername}
|
||||
@ -76,8 +76,8 @@ class CommentsView extends PureComponent {
|
||||
handleOnReplyPress={handleOnReplyPress}
|
||||
handleOnUserPress={handleOnUserPress}
|
||||
isLoggedIn={isLoggedIn}
|
||||
isShowMoreButton={commentNumber === 1 && item.children > 0}
|
||||
voteCount={item.net_votes}
|
||||
isShowMoreButton={commentNumber === 1 && get(item, 'children') > 0}
|
||||
voteCount={get(item, 'vote_count')}
|
||||
isShowSubComments={isShowSubComments}
|
||||
key={item.permlink}
|
||||
marginLeft={marginLeft}
|
||||
|
@ -82,7 +82,7 @@ class PostCardContainer extends PureComponent {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { content, isHideImage, nsfw } = this.props;
|
||||
const { content, isHideImage, nsfw, isHideReblogOption } = this.props;
|
||||
const { _content } = this.state;
|
||||
|
||||
const isNsfwPost = nsfw === '1';
|
||||
@ -96,6 +96,7 @@ class PostCardContainer extends PureComponent {
|
||||
content={_content || content}
|
||||
isHideImage={isHideImage}
|
||||
isNsfwPost={isNsfwPost}
|
||||
isHideReblogOption={isHideReblogOption}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class PostCardView extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { content, isHideImage, fetchPost, isNsfwPost } = this.props;
|
||||
const { content, isHideImage, fetchPost, isNsfwPost, isHideReblogOption } = this.props;
|
||||
|
||||
const _image = this._getPostImage(content, isNsfwPost);
|
||||
const reblogedBy = content.reblogged_by && content.reblogged_by[0];
|
||||
@ -88,7 +88,11 @@ class PostCardView extends Component {
|
||||
reblogedBy={reblogedBy}
|
||||
/>
|
||||
<View style={styles.dropdownWrapper}>
|
||||
<PostDropdown content={content} fetchPost={fetchPost} />
|
||||
<PostDropdown
|
||||
isHideReblogOption={isHideReblogOption}
|
||||
content={content}
|
||||
fetchPost={fetchPost}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.postBodyWrapper}>
|
||||
|
@ -173,10 +173,10 @@ class PostDropdownContainer extends PureComponent {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { intl, currentAccount, content } = this.props;
|
||||
const { intl, currentAccount, content, isHideReblogOption } = this.props;
|
||||
let _OPTIONS = OPTIONS;
|
||||
|
||||
if (content && content.author === currentAccount.name) {
|
||||
if ((content && content.author === currentAccount.name) || isHideReblogOption) {
|
||||
_OPTIONS = OPTIONS.filter(item => item !== 'reblog');
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ class PostDisplayView extends PureComponent {
|
||||
<Tags tags={post.json_metadata && post.json_metadata.tags} />
|
||||
<Text style={styles.footerText}>
|
||||
Posted by
|
||||
<Text style={styles.footerName}>{author || post.author}</Text>
|
||||
<Text style={styles.footerName}>{` ${author || post.author} `}</Text>
|
||||
{formatedTime}
|
||||
</Text>
|
||||
{/* {isPostEnd && this._getTabBar()} */}
|
||||
|
@ -233,6 +233,7 @@ class PostsView extends Component {
|
||||
isLoginDone,
|
||||
tag,
|
||||
isDarkTheme,
|
||||
isHideReblogOption,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@ -267,7 +268,12 @@ class PostsView extends Component {
|
||||
data={posts}
|
||||
showsVerticalScrollIndicator={false}
|
||||
renderItem={({ item }) => (
|
||||
<PostCard isRefresh={refreshing} content={item} isHideImage={isHideImage} />
|
||||
<PostCard
|
||||
isHideReblogOption={isHideReblogOption}
|
||||
isRefresh={refreshing}
|
||||
content={item}
|
||||
isHideImage={isHideImage}
|
||||
/>
|
||||
)}
|
||||
keyExtractor={(post, index) => index.toString()}
|
||||
onEndReached={() => this._loadPosts()}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import get from 'lodash/get';
|
||||
|
||||
// Realm
|
||||
import { setUpvotePercent } from '../../../realm/realm';
|
||||
@ -50,31 +51,21 @@ class UpvoteContainer extends PureComponent {
|
||||
upvotePercent,
|
||||
globalProps,
|
||||
} = this.props;
|
||||
let author;
|
||||
let authorPayout;
|
||||
let curationPayout;
|
||||
let isDecinedPayout;
|
||||
let isVoted;
|
||||
let payoutDate;
|
||||
let pendingPayout;
|
||||
let permlink;
|
||||
let promotedPayout;
|
||||
let totalPayout;
|
||||
|
||||
if (content) {
|
||||
({ author } = content);
|
||||
isVoted = content.is_voted;
|
||||
totalPayout = content.total_payout;
|
||||
isDecinedPayout = content.is_declined_payout;
|
||||
({ permlink } = content);
|
||||
pendingPayout = parseToken(content.pending_payout_value).toFixed(3);
|
||||
promotedPayout = parseToken(content.promoted).toFixed(3);
|
||||
authorPayout = parseToken(content.total_payout_value).toFixed(3);
|
||||
curationPayout = parseToken(content.curator_payout_value).toFixed(3);
|
||||
payoutDate = getTimeFromNow(
|
||||
isEmptyContentDate(content.last_payout) ? content.cashout_time : content.last_payout,
|
||||
);
|
||||
}
|
||||
const author = get(content, 'author');
|
||||
const isVoted = get(content, 'is_voted');
|
||||
const totalPayout = get(content, 'total_payout');
|
||||
const isDecinedPayout = get(content, 'is_declined_payout');
|
||||
const permlink = get(content, 'permlink');
|
||||
const pendingPayout = parseToken(get(content, 'pending_payout_value', 0)).toFixed(3);
|
||||
const promotedPayout = parseToken(get(content, 'promoted', 0)).toFixed(3);
|
||||
const authorPayout = parseToken(get(content, 'total_payout_value', 0)).toFixed(3);
|
||||
const curationPayout = parseToken(get(content, 'curator_payout_value', 0)).toFixed(3);
|
||||
const payoutDate = getTimeFromNow(
|
||||
isEmptyContentDate(get(content, 'last_payout'))
|
||||
? get(content, 'cashout_time')
|
||||
: get(content, 'last_payout'),
|
||||
);
|
||||
|
||||
return (
|
||||
<UpvoteView
|
||||
|
@ -3,6 +3,7 @@ import { View, TouchableOpacity, Text, Alert } from 'react-native';
|
||||
import { injectIntl } from 'react-intl';
|
||||
import { Popover, PopoverController } from 'react-native-modal-popover';
|
||||
import Slider from 'react-native-slider';
|
||||
import get from 'lodash/get';
|
||||
|
||||
// Utils
|
||||
import parseToken from '../../../utils/parseToken';
|
||||
@ -29,9 +30,9 @@ class UpvoteView extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
sliderValue: props.upvotePercent || 1,
|
||||
sliderValue: get(props, 'upvotePercent', 1),
|
||||
isVoting: false,
|
||||
isVoted: props.isVoted,
|
||||
isVoted: get(props, 'isVoted', false),
|
||||
amount: '0.00000',
|
||||
isShowDetails: false,
|
||||
};
|
||||
@ -46,12 +47,12 @@ class UpvoteView extends Component {
|
||||
const { isVoted, upvotePercent } = this.props;
|
||||
const { isVoted: localIsVoted } = this.state;
|
||||
|
||||
if (isVoted !== nextProps.isVoted && localIsVoted !== nextProps.isVoted) {
|
||||
this.setState({ isVoted: nextProps.isVoted });
|
||||
if (isVoted !== get(nextProps, 'isVoted') && localIsVoted !== get(nextProps, 'isVoted')) {
|
||||
this.setState({ isVoted: get(nextProps, 'isVoted') });
|
||||
}
|
||||
|
||||
if (upvotePercent !== nextProps.upvotePercent) {
|
||||
this.setState({ sliderValue: nextProps.upvotePercent });
|
||||
if (upvotePercent !== get(nextProps, 'upvotePercent')) {
|
||||
this.setState({ sliderValue: get(nextProps, 'upvotePercent') });
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,9 +66,9 @@ class UpvoteView extends Component {
|
||||
|
||||
const votingPower = currentAccount.voting_power;
|
||||
const totalVests =
|
||||
parseToken(currentAccount.vesting_shares) +
|
||||
parseToken(currentAccount.received_vesting_shares) -
|
||||
parseToken(currentAccount.delegated_vesting_shares);
|
||||
parseToken(get(currentAccount, 'vesting_shares')) +
|
||||
parseToken(get(currentAccount, 'received_vesting_shares')) -
|
||||
parseToken(get(currentAccount, 'delegated_vesting_shares'));
|
||||
const votePct = sliderValue * 10000;
|
||||
|
||||
const rShares = vestsToRshares(totalVests, votingPower, votePct);
|
||||
|
@ -65,13 +65,13 @@ export const fetchGlobalProps = async () => {
|
||||
}
|
||||
|
||||
const steemPerMVests =
|
||||
(parseToken(globalDynamic.total_vesting_fund_steem) /
|
||||
parseToken(globalDynamic.total_vesting_shares)) *
|
||||
(parseToken(get(globalDynamic, 'total_vesting_fund_steem')) /
|
||||
parseToken(get(globalDynamic, 'total_vesting_shares'))) *
|
||||
1e6;
|
||||
const base = parseToken(feedHistory.current_median_history.base);
|
||||
const quote = parseToken(feedHistory.current_median_history.quote);
|
||||
const fundRecentClaims = rewardFund.recent_claims;
|
||||
const fundRewardBalance = parseToken(rewardFund.reward_balance);
|
||||
const base = parseToken(get(feedHistory, 'current_median_history.base'));
|
||||
const quote = parseToken(get(feedHistory, 'current_median_history.quote'));
|
||||
const fundRecentClaims = get(rewardFund, 'recent_claims');
|
||||
const fundRewardBalance = parseToken(get(rewardFund, 'reward_balance'));
|
||||
const globalProps = {
|
||||
steemPerMVests,
|
||||
base,
|
||||
@ -140,19 +140,20 @@ export const getUser = async user => {
|
||||
globalProperties.total_vesting_fund_steem,
|
||||
);
|
||||
account[0].received_steem_power = await vestToSteem(
|
||||
account[0].received_vesting_shares,
|
||||
globalProperties.total_vesting_shares,
|
||||
globalProperties.total_vesting_fund_steem,
|
||||
get(account[0], 'received_vesting_shares'),
|
||||
get(globalProperties, 'total_vesting_shares'),
|
||||
get(globalProperties, 'total_vesting_fund_steem'),
|
||||
);
|
||||
account[0].delegated_steem_power = await vestToSteem(
|
||||
account[0].delegated_vesting_shares,
|
||||
globalProperties.total_vesting_shares,
|
||||
globalProperties.total_vesting_fund_steem,
|
||||
get(account[0], 'delegated_vesting_shares'),
|
||||
get(globalProperties, 'total_vesting_shares'),
|
||||
get(globalProperties, 'total_vesting_fund_steem'),
|
||||
);
|
||||
|
||||
account[0].about = account[0].json_metadata && JSON.parse(account[0].json_metadata);
|
||||
account[0].avatar = getAvatar(account[0].about);
|
||||
account[0].display_name = getName(account[0].about);
|
||||
account[0].about =
|
||||
get(account[0], 'json_metadata') && JSON.parse(get(account[0], 'json_metadata'));
|
||||
account[0].avatar = getAvatar(get(account[0], 'about'));
|
||||
account[0].display_name = getName(get(account[0], 'about'));
|
||||
|
||||
return account[0];
|
||||
} catch (error) {
|
||||
@ -289,7 +290,16 @@ export const getPosts = async (by, query, user) => {
|
||||
};
|
||||
|
||||
export const getActiveVotes = (author, permlink) =>
|
||||
client.database.call('get_active_votes', [author, permlink]);
|
||||
new Promise((resolve, reject) => {
|
||||
client.database
|
||||
.call('get_active_votes', [author, permlink])
|
||||
.then(result => {
|
||||
resolve(result);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
export const getPostsSummary = async (by, query, currentUserName, filterNsfw) => {
|
||||
try {
|
||||
@ -312,7 +322,7 @@ export const getPostsSummary = async (by, query, currentUserName, filterNsfw) =>
|
||||
export const getUserComments = async query => {
|
||||
try {
|
||||
let comments = await client.database.getDiscussions('comments', query);
|
||||
comments = parseComments(comments);
|
||||
comments = await parseComments(comments);
|
||||
return comments;
|
||||
} catch (error) {
|
||||
return error;
|
||||
@ -326,7 +336,7 @@ export const getRepliesByLastUpdate = async query => {
|
||||
query.start_permlink,
|
||||
query.limit,
|
||||
]);
|
||||
replies = parseComments(replies);
|
||||
replies = await parseComments(replies);
|
||||
return replies;
|
||||
} catch (error) {
|
||||
return error;
|
||||
@ -395,26 +405,20 @@ export const deleteComment = (currentAccount, pin, permlink) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @method getUser get user data
|
||||
* @param user post author
|
||||
* @param permlink post permlink
|
||||
*/
|
||||
export const getComments = (user, permlink) => {
|
||||
let comments;
|
||||
return new Promise((resolve, reject) => {
|
||||
client.database
|
||||
.call('get_content_replies', [user, permlink])
|
||||
.then(result => {
|
||||
comments = parseComments(result);
|
||||
})
|
||||
.then(() => {
|
||||
resolve(comments);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
const wait = ms => new Promise(r => setTimeout(r, ms));
|
||||
|
||||
export const getComments = async (author, permlink, currentUserName = null) => {
|
||||
try {
|
||||
const comments = await client.database.call('get_content_replies', [author, permlink]);
|
||||
|
||||
const groomedComments = await parseComments(comments, currentUserName);
|
||||
// WORK ARROUND
|
||||
await wait(comments && comments.length * 30);
|
||||
|
||||
return comments ? groomedComments : null;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -517,15 +521,15 @@ export const upvoteAmount = async input => {
|
||||
|
||||
export const transferToken = (currentAccount, pin, data) => {
|
||||
const digitPinCode = getDigitPinCode(pin);
|
||||
const key = getAnyPrivateKey({ activeKey: currentAccount.local.activeKey }, digitPinCode);
|
||||
const key = getAnyPrivateKey({ activeKey: get(currentAccount, 'local.activeKey') }, digitPinCode);
|
||||
|
||||
if (key) {
|
||||
const privateKey = PrivateKey.fromString(key);
|
||||
const args = {
|
||||
from: data.from,
|
||||
to: data.destination,
|
||||
amount: data.amount,
|
||||
memo: data.memo,
|
||||
from: get(data, 'from'),
|
||||
to: get(data, 'destination'),
|
||||
amount: get(data, 'amount'),
|
||||
memo: get(data, 'memo'),
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -533,7 +537,7 @@ export const transferToken = (currentAccount, pin, data) => {
|
||||
.transfer(args, privateKey)
|
||||
.then(result => {
|
||||
if (result) {
|
||||
transfer(data.from, data.destination, data.ammount);
|
||||
transfer(get(data, 'from'), get(data, 'destination'), get(data, 'ammount'));
|
||||
resolve(result);
|
||||
}
|
||||
})
|
||||
@ -548,7 +552,7 @@ export const transferToken = (currentAccount, pin, data) => {
|
||||
|
||||
export const transferToSavings = (currentAccount, pin, data) => {
|
||||
const digitPinCode = getDigitPinCode(pin);
|
||||
const key = getAnyPrivateKey({ activeKey: currentAccount.local.activeKey }, digitPinCode);
|
||||
const key = getAnyPrivateKey({ activeKey: get(currentAccount, 'local.activeKey') }, digitPinCode);
|
||||
|
||||
if (key) {
|
||||
const privateKey = PrivateKey.fromString(key);
|
||||
@ -557,10 +561,10 @@ export const transferToSavings = (currentAccount, pin, data) => {
|
||||
[
|
||||
'transfer_to_savings',
|
||||
{
|
||||
from: data.from,
|
||||
to: data.destination,
|
||||
amount: data.amount,
|
||||
memo: data.memo,
|
||||
from: get(data, 'from'),
|
||||
to: get(data, 'destination'),
|
||||
amount: get(data, 'amount'),
|
||||
memo: get(data, 'memo'),
|
||||
},
|
||||
],
|
||||
];
|
||||
@ -582,7 +586,7 @@ export const transferToSavings = (currentAccount, pin, data) => {
|
||||
|
||||
export const transferFromSavings = (currentAccount, pin, data) => {
|
||||
const digitPinCode = getDigitPinCode(pin);
|
||||
const key = getAnyPrivateKey({ activeKey: currentAccount.local.activeKey }, digitPinCode);
|
||||
const key = getAnyPrivateKey({ activeKey: get(currentAccount, 'local.activeKey') }, digitPinCode);
|
||||
|
||||
if (key) {
|
||||
const privateKey = PrivateKey.fromString(key);
|
||||
@ -590,11 +594,11 @@ export const transferFromSavings = (currentAccount, pin, data) => {
|
||||
[
|
||||
'transfer_from_savings',
|
||||
{
|
||||
from: data.from,
|
||||
to: data.destination,
|
||||
amount: data.amount,
|
||||
memo: data.memo,
|
||||
request_id: data.requestId,
|
||||
from: get(data, 'from'),
|
||||
to: get(data, 'destination'),
|
||||
amount: get(data, 'amount'),
|
||||
memo: get(data, 'memo'),
|
||||
request_id: get(data, 'requestId'),
|
||||
},
|
||||
],
|
||||
];
|
||||
@ -616,7 +620,7 @@ export const transferFromSavings = (currentAccount, pin, data) => {
|
||||
|
||||
export const transferToVesting = (currentAccount, pin, data) => {
|
||||
const digitPinCode = getDigitPinCode(pin);
|
||||
const key = getAnyPrivateKey({ activeKey: currentAccount.local.activeKey }, digitPinCode);
|
||||
const key = getAnyPrivateKey({ activeKey: get(currentAccount, 'local.activeKey') }, digitPinCode);
|
||||
|
||||
if (key) {
|
||||
const privateKey = PrivateKey.fromString(key);
|
||||
@ -651,7 +655,7 @@ export const followUser = async (currentAccount, pin, data) => {
|
||||
const key = getAnyPrivateKey(currentAccount.local, digitPinCode);
|
||||
|
||||
if (currentAccount.local.authType === AUTH_TYPE.STEEM_CONNECT) {
|
||||
const token = decryptKey(currentAccount.local.accessToken, digitPinCode);
|
||||
const token = decryptKey(get(currentAccount, 'local.accessToken'), digitPinCode);
|
||||
const api = steemConnect.Initialize({
|
||||
accessToken: token,
|
||||
});
|
||||
@ -982,15 +986,15 @@ const _reblog = async (account, pinCode, author, permlink) => {
|
||||
|
||||
export const claimRewardBalance = (account, pinCode, rewardSteem, rewardSbd, rewardVests) => {
|
||||
const pin = getDigitPinCode(pinCode);
|
||||
const key = getAnyPrivateKey(account.local, pin);
|
||||
const key = getAnyPrivateKey(get(account, 'local'), pin);
|
||||
|
||||
if (account.local.authType === AUTH_TYPE.STEEM_CONNECT) {
|
||||
const token = decryptKey(account.local.accessToken, pin);
|
||||
const token = decryptKey(get(account, 'local.accessToken'), pin);
|
||||
const api = steemConnect.Initialize({
|
||||
accessToken: token,
|
||||
});
|
||||
|
||||
return api.claimRewardBalance(account.name, rewardSteem, rewardSbd, rewardVests);
|
||||
return api.claimRewardBalance(get(account, 'name'), rewardSteem, rewardSbd, rewardVests);
|
||||
}
|
||||
|
||||
if (key) {
|
||||
@ -1016,7 +1020,7 @@ export const claimRewardBalance = (account, pinCode, rewardSteem, rewardSbd, rew
|
||||
|
||||
export const transferPoint = (currentAccount, pinCode, data) => {
|
||||
const pin = getDigitPinCode(pinCode);
|
||||
const key = getActiveKey(currentAccount.local, pin);
|
||||
const key = getActiveKey(get(currentAccount, 'local'), pin);
|
||||
const username = get(currentAccount, 'name');
|
||||
|
||||
const json = JSON.stringify({
|
||||
|
@ -1,10 +1,8 @@
|
||||
import React, { Component } from 'react';
|
||||
import get from 'lodash/get';
|
||||
|
||||
// Middleware
|
||||
|
||||
// Constants
|
||||
import { default as ROUTES } from '../../../constants/routeNames';
|
||||
|
||||
// Utilities
|
||||
|
||||
// Services and Actions
|
||||
@ -83,11 +81,13 @@ class FollowsContainer extends Component {
|
||||
};
|
||||
|
||||
_handleSearch = async text => {
|
||||
const { users, username } = this.state;
|
||||
const { users, username, isFollowingPress } = this.state;
|
||||
let newData;
|
||||
|
||||
newData = users.filter(item => {
|
||||
const itemName = item.follower.toUpperCase();
|
||||
const itemName = isFollowingPress
|
||||
? get(item, 'following').toUpperCase()
|
||||
: get(item, 'follower').toUpperCase();
|
||||
const _text = text.toUpperCase();
|
||||
|
||||
return itemName.indexOf(_text) > -1;
|
||||
|
@ -1,6 +1,8 @@
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { withNavigation } from 'react-navigation';
|
||||
import get from 'lodash/get';
|
||||
|
||||
// Services and Actions
|
||||
import { getPost } from '../../../providers/steem/dsteem';
|
||||
|
||||
@ -29,8 +31,10 @@ class PostContainer extends Component {
|
||||
// Component Life Cycle Functions
|
||||
componentDidMount() {
|
||||
const { navigation } = this.props;
|
||||
const { content, permlink, author, isNewPost, isHasParentPost } =
|
||||
navigation.state && navigation.state.params;
|
||||
const { content, permlink, author, isNewPost, isHasParentPost } = get(
|
||||
navigation,
|
||||
'state.params',
|
||||
);
|
||||
|
||||
if (isNewPost) this.setState({ isNewPost });
|
||||
|
||||
@ -45,11 +49,10 @@ class PostContainer extends Component {
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { navigation } = this.props;
|
||||
const { isFetch: nextIsFetch } =
|
||||
nextProps.navigation.state && nextProps.navigation.state.params;
|
||||
const { isFetch: nextIsFetch } = get(nextProps, 'navigation.state.params');
|
||||
|
||||
if (nextIsFetch) {
|
||||
const { author, permlink } = navigation.state && navigation.state.params;
|
||||
const { author, permlink } = get(navigation, 'state.params');
|
||||
|
||||
this._loadPost(author, permlink);
|
||||
}
|
||||
@ -61,12 +64,12 @@ class PostContainer extends Component {
|
||||
const { currentAccount, isLoggedIn } = this.props;
|
||||
const { post } = this.state;
|
||||
|
||||
const _author = author || post.author;
|
||||
const _permlink = permlink || post.permlink;
|
||||
const _author = author || get(post, 'author');
|
||||
const _permlink = permlink || get(post, 'permlink');
|
||||
|
||||
await getPost(_author, _permlink, isLoggedIn && currentAccount.username)
|
||||
await getPost(_author, _permlink, isLoggedIn && get(currentAccount, 'username'))
|
||||
.then(result => {
|
||||
if (result && result.id > 0) {
|
||||
if (get(result, 'id', 0) > 0) {
|
||||
if (isParentPost) {
|
||||
this.setState({ parentPost: result });
|
||||
} else {
|
||||
@ -93,7 +96,8 @@ class PostContainer extends Component {
|
||||
author,
|
||||
} = this.state;
|
||||
|
||||
if (isHasParentPost && post) this._loadPost(post.parent_author, post.parent_permlink, true);
|
||||
if (isHasParentPost && post)
|
||||
this._loadPost(get(post, 'parent_author'), get(post, 'parent_permlink'), true);
|
||||
|
||||
return (
|
||||
<PostScreen
|
||||
|
@ -210,6 +210,7 @@ class ProfileScreen extends PureComponent {
|
||||
handleOnScroll={this._handleOnScroll}
|
||||
forceLoadPost={forceLoadPost}
|
||||
changeForceLoadPostState={changeForceLoadPostState}
|
||||
isHideReblogOption
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
|
@ -1,6 +1,12 @@
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import forEach from 'lodash/forEach';
|
||||
import get from 'lodash/get';
|
||||
|
||||
import { postBodySummary, renderPostBody } from '@esteemapp/esteem-render-helpers';
|
||||
|
||||
// Dsteem
|
||||
import { getActiveVotes } from '../providers/steem/dsteem';
|
||||
|
||||
// Utils
|
||||
import { getReputation } from './reputation';
|
||||
|
||||
@ -47,7 +53,7 @@ export const parsePost = (post, currentUserName) => {
|
||||
forEach(post.active_votes, value => {
|
||||
post.vote_perecent = value.voter === currentUserName ? value.percent : null;
|
||||
value.value = (value.rshares * ratio).toFixed(3);
|
||||
value.reputation = getReputation(value.reputation);
|
||||
value.reputation = getReputation(get(value, 'reputation'));
|
||||
value.percent /= 100;
|
||||
value.is_down_vote = Math.sign(value.percent) < 0;
|
||||
value.avatar = `https://steemitimages.com/u/${value.voter}/avatar/small`;
|
||||
@ -57,9 +63,6 @@ export const parsePost = (post, currentUserName) => {
|
||||
return post;
|
||||
};
|
||||
|
||||
const isVoted = (activeVotes, currentUserName) =>
|
||||
activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
|
||||
|
||||
const postImage = (metaData, body) => {
|
||||
const imgTagRegex = /(<img[^>]*>)/g;
|
||||
const markdownImageRegex = /!\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\)/g;
|
||||
@ -98,15 +101,31 @@ const postImage = (metaData, body) => {
|
||||
return '';
|
||||
};
|
||||
|
||||
export const parseComments = comments => {
|
||||
forEach(comments, comment => {
|
||||
comment.pending_payout_value = parseFloat(comment.pending_payout_value).toFixed(3);
|
||||
comment.vote_count = comment.active_votes.length;
|
||||
comment.author_reputation = getReputation(comment.author_reputation);
|
||||
comment.avatar = `https://steemitimages.com/u/${comment.author}/avatar/small`;
|
||||
comment.markdownBody = comment.body;
|
||||
export const parseComments = async (comments, currentUserName) => {
|
||||
const _comments = await comments.map(async comment => {
|
||||
const activeVotes = await getActiveVotes(get(comment, 'author'), get(comment, 'permlink'));
|
||||
|
||||
comment.pending_payout_value = parseFloat(
|
||||
get(comment, 'pending_payout_value') ? get(comment, 'pending_payout_value') : 0,
|
||||
).toFixed(3);
|
||||
comment.author_reputation = getReputation(get(comment, 'author_reputation'));
|
||||
comment.avatar = `https://steemitimages.com/u/${get(comment, 'author')}/avatar/small`;
|
||||
comment.markdownBody = get(comment, 'body');
|
||||
comment.body = renderPostBody(comment);
|
||||
comment.summary = `"${postBodySummary(comment, 100, true)}"`;
|
||||
comment.active_votes = activeVotes;
|
||||
comment.vote_count = activeVotes && activeVotes.length;
|
||||
|
||||
if (currentUserName && activeVotes && activeVotes.length > 0) {
|
||||
comment.is_voted = isVoted(activeVotes, currentUserName);
|
||||
} else {
|
||||
comment.is_voted = false;
|
||||
}
|
||||
|
||||
return _comments;
|
||||
});
|
||||
|
||||
return comments;
|
||||
};
|
||||
|
||||
const isVoted = (activeVotes, currentUserName) =>
|
||||
activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
|
||||
|
Loading…
Reference in New Issue
Block a user