mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-02 10:54:59 +03:00
updated vote updater in post detail section
This commit is contained in:
parent
8fa48fca62
commit
8cb950adb0
@ -28,7 +28,6 @@ const PostCardContainer = ({
|
|||||||
isHideImage,
|
isHideImage,
|
||||||
nsfw,
|
nsfw,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
const [_content, setContent] = useState(content);
|
const [_content, setContent] = useState(content);
|
||||||
const [reblogs, setReblogs] = useState([]);
|
const [reblogs, setReblogs] = useState([]);
|
||||||
const [activeVotes, setActiveVotes] = useState(get(_content, 'active_votes', []));
|
const [activeVotes, setActiveVotes] = useState(get(_content, 'active_votes', []));
|
||||||
|
@ -67,9 +67,8 @@ const PostCardView = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const _handleIncrementVoteCount = () => {
|
const _handleIncrementVoteCount = () => {
|
||||||
setActiveVotesCount(activeVotesCount + 1)
|
setActiveVotesCount(activeVotesCount + 1);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// if (content) {
|
// if (content) {
|
||||||
|
@ -46,6 +46,7 @@ const PostDisplayView = ({
|
|||||||
const [isLoadedComments, setIsLoadedComments] = useState(false);
|
const [isLoadedComments, setIsLoadedComments] = useState(false);
|
||||||
const actionSheet = useRef(null);
|
const actionSheet = useRef(null);
|
||||||
const [refreshing, setRefreshing] = useState(false);
|
const [refreshing, setRefreshing] = useState(false);
|
||||||
|
const [activeVotesCount, setActiveVotesCount] = useState(activeVotes.length || 0)
|
||||||
|
|
||||||
// Component Life Cycles
|
// Component Life Cycles
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -78,6 +79,10 @@ const PostDisplayView = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const _handleIncrementActiveVotesCount = () =>{
|
||||||
|
setActiveVotesCount(activeVotesCount + 1);
|
||||||
|
}
|
||||||
|
|
||||||
const _getTabBar = (isFixedFooter = false) => {
|
const _getTabBar = (isFixedFooter = false) => {
|
||||||
return (
|
return (
|
||||||
<SafeAreaView>
|
<SafeAreaView>
|
||||||
@ -85,9 +90,9 @@ const PostDisplayView = ({
|
|||||||
<View style={styles.stickyWrapper}>
|
<View style={styles.stickyWrapper}>
|
||||||
<Upvote
|
<Upvote
|
||||||
activeVotes={activeVotes}
|
activeVotes={activeVotes}
|
||||||
fetchPost={fetchPost}
|
|
||||||
isShowPayoutValue
|
isShowPayoutValue
|
||||||
content={post}
|
content={post}
|
||||||
|
incrementVoteCount={_handleIncrementActiveVotesCount}
|
||||||
/>
|
/>
|
||||||
<TextWithIcon
|
<TextWithIcon
|
||||||
iconName="heart-outline"
|
iconName="heart-outline"
|
||||||
@ -95,7 +100,7 @@ const PostDisplayView = ({
|
|||||||
iconType="MaterialCommunityIcons"
|
iconType="MaterialCommunityIcons"
|
||||||
isClickable
|
isClickable
|
||||||
onPress={() => handleOnVotersPress && handleOnVotersPress()}
|
onPress={() => handleOnVotersPress && handleOnVotersPress()}
|
||||||
text={activeVotes.length}
|
text={activeVotesCount}
|
||||||
textMarginLeft={20}
|
textMarginLeft={20}
|
||||||
/>
|
/>
|
||||||
<TextWithIcon
|
<TextWithIcon
|
||||||
|
@ -39,7 +39,7 @@ const UpvoteContainer = (props) => {
|
|||||||
|
|
||||||
const [isVoted, setIsVoted] = useState(null);
|
const [isVoted, setIsVoted] = useState(null);
|
||||||
const [isDownVoted, setIsDownVoted] = useState(null);
|
const [isDownVoted, setIsDownVoted] = useState(null);
|
||||||
const [totalPayout, setTotalPayout] = useState(get(content, 'total_payout'))
|
const [totalPayout, setTotalPayout] = useState(get(content, 'total_payout'));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
_calculateVoteStatus();
|
_calculateVoteStatus();
|
||||||
@ -64,10 +64,10 @@ const UpvoteContainer = (props) => {
|
|||||||
//do all relevant processing here to show local upvote
|
//do all relevant processing here to show local upvote
|
||||||
const amountNum = parseFloat(amount);
|
const amountNum = parseFloat(amount);
|
||||||
|
|
||||||
setTotalPayout(totalPayout + amountNum)
|
setTotalPayout(totalPayout + amountNum);
|
||||||
|
|
||||||
if (!isVoted && !isDownVoted && incrementVoteCount) {
|
if (!isVoted && !isDownVoted && incrementVoteCount) {
|
||||||
incrementVoteCount()
|
incrementVoteCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDownvote) {
|
if (isDownvote) {
|
||||||
@ -75,8 +75,7 @@ const UpvoteContainer = (props) => {
|
|||||||
} else {
|
} else {
|
||||||
setIsVoted(true);
|
setIsVoted(true);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const author = get(content, 'author');
|
const author = get(content, 'author');
|
||||||
const isDecinedPayout = get(content, 'is_declined_payout');
|
const isDecinedPayout = get(content, 'is_declined_payout');
|
||||||
|
@ -91,7 +91,7 @@ class UpvoteView extends Component {
|
|||||||
|
|
||||||
const weight = sliderValue ? (sliderValue * 100).toFixed(0) * 100 : 0;
|
const weight = sliderValue ? (sliderValue * 100).toFixed(0) * 100 : 0;
|
||||||
|
|
||||||
console.log("casting up vote: " + weight);
|
console.log('casting up vote: ' + weight);
|
||||||
vote(currentAccount, pinCode, author, permlink, weight)
|
vote(currentAccount, pinCode, author, permlink, weight)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.setState(
|
this.setState(
|
||||||
@ -102,10 +102,10 @@ class UpvoteView extends Component {
|
|||||||
() => {
|
() => {
|
||||||
//add snippet to update amount and active vote count
|
//add snippet to update amount and active vote count
|
||||||
|
|
||||||
onVote(amount, false)
|
onVote(amount, false);
|
||||||
|
|
||||||
if (fetchPost) {
|
if (fetchPost) {
|
||||||
console.log("fetching post")
|
console.log('fetching post');
|
||||||
fetchPost();
|
fetchPost();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -189,7 +189,7 @@ class UpvoteView extends Component {
|
|||||||
|
|
||||||
const weight = sliderValue ? (sliderValue * 100).toFixed(0) * 100 * -1 : 0;
|
const weight = sliderValue ? (sliderValue * 100).toFixed(0) * 100 * -1 : 0;
|
||||||
|
|
||||||
console.log("casting down vote: " + weight);
|
console.log('casting down vote: ' + weight);
|
||||||
vote(currentAccount, pinCode, author, permlink, weight)
|
vote(currentAccount, pinCode, author, permlink, weight)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.setState(
|
this.setState(
|
||||||
@ -198,11 +198,10 @@ class UpvoteView extends Component {
|
|||||||
isVoting: false,
|
isVoting: false,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
|
onVote(amount, true);
|
||||||
onVote(amount, true)
|
|
||||||
|
|
||||||
if (fetchPost) {
|
if (fetchPost) {
|
||||||
console.log("Fetching post")
|
console.log('Fetching post');
|
||||||
fetchPost();
|
fetchPost();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -649,7 +649,7 @@ export const signImage = async (file, currentAccount, pin) => {
|
|||||||
export const vote = (account, pin, author, permlink, weight) =>
|
export const vote = (account, pin, author, permlink, weight) =>
|
||||||
_vote(account, pin, author, permlink, weight).then((resp) => {
|
_vote(account, pin, author, permlink, weight).then((resp) => {
|
||||||
userActivity(account.username, 120, resp.block_num, resp.id);
|
userActivity(account.username, 120, resp.block_num, resp.id);
|
||||||
console.log("Returning vote response");
|
console.log('Returning vote response');
|
||||||
return resp;
|
return resp;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user