New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add current voting power to UserInfo #927
Conversation
src/app/Sidebar/UserInfo.js
Outdated
@@ -57,6 +59,13 @@ const UserInfo = ({ intl, authenticated, authenticatedUser, user, ...props }) => | |||
}} | |||
/> | |||
</div> | |||
<div> | |||
<i className="iconfont icon-flashlight text-icon" /> | |||
{intl.formatMessage({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use FormattedMessage
from react-intl
instead of this?
src/app/Sidebar/UserInfo.js
Outdated
{intl.formatMessage({ | ||
id: 'voting_power', | ||
defaultMessage: 'Voting Power', | ||
})}: {currentVotingPower} % |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use FormattedNumber
from react-intl
instead of this as well?
Like here:
busy/src/components/Reactions/ReactionsList.js
Lines 48 to 51 in 493639e
<FormattedNumber | |
style="percent" // eslint-disable-line react/style-prop-object | |
value={vote.percent / 10000} | |
/> |
I don't know if I use it correctly and I also don't know why I have to divide by 10000 but... it works. |
<i className="iconfont icon-flashlight text-icon" /> | ||
<FormattedMessage id="voting_power" defaultMessage="Voting Power" />: <FormattedNumber | ||
style="percent" // eslint-disable-line react/style-prop-object | ||
value={user.voting_power / 10000} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to get the percent of something you divide it by the total... so is 10,000 the total voting power that a user can have? @Sekhmet @bonustrack might know the answer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jm90m
Steem uses 0-10000 range (10000 being 100%). react-intl
uses 0-1 range, thus we need to divide it by 10000.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok.... so style="percent"
transforms 0-1 to 0-100? Can't find this transformation in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just tells react-intl
to render this as per cent.
https://github.com/yahoo/react-intl/wiki/Components#formattednumber
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea and well done thank you!
In the left sidebar, when viewing a user's profile, the current voting power is now shown.
In a future PR this should be implemented:
I took this code from another project. It takes into account the replenishment of the voting power since the last vote.