Skip to content

Commit

Permalink
fix visualization of votes
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Schiessl <stefan.schiessl@blockchainprojectsbv.com>
  • Loading branch information
Stefan Schiessl committed May 21, 2019
1 parent 77868cc commit 5376c5b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 36 deletions.
3 changes: 3 additions & 0 deletions app/assets/locales/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1553,12 +1553,15 @@
"call_order_update": "Change {account} {debtSymbol} debt by {debt} and collateral by {collateral}",
"changes_to_active": "Changes to active",
"changes_to_owner": "Changes to owner",
"changes_to_memo": "Changes to memo",
"committee_member_update_global_parameters": "Update committee global parameters by {account}",
"delete": "Permanently reject",
"danger_operation": "Dangerous operation",
"set_threshold": "Set threshold to %(threshold)s",
"add": "Add",
"remove": "Remove",
"add_vote": "Add vote for",
"remove_vote": "Remove vote for",
"expires": "Expires",
"feed_producer": "Update the feed producers for the asset {asset} using the account {account}",
"limit_order_buy": "Place an order to buy {amount} at {price} for {account}",
Expand Down
6 changes: 0 additions & 6 deletions app/components/Account/RecentTransactions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class RecentTransactions extends React.Component {
};
this.getDataSource = this.getDataSource.bind(this);

this.forceUpdate = this.forceUpdate.bind(this);
this.useCustom = counterpart.translate(
"account.export_modal.use_custom"
);
Expand All @@ -105,7 +104,6 @@ class RecentTransactions extends React.Component {

this._setHeaderHeight();
}
ChainStore.subscribe(this.forceUpdate);
}

esNodeChange(e) {
Expand Down Expand Up @@ -194,10 +192,6 @@ class RecentTransactions extends React.Component {
return false;
}

componentWillUnmount() {
ChainStore.unsubscribe(this.forceUpdate);
}

_onIncreaseLimit() {
this.setState({
limit: this.state.limit + 30
Expand Down
47 changes: 38 additions & 9 deletions app/components/Blockchain/operations/AccountUpdate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,35 @@ const compareKeys = (prev, next) => {
};

const getVotesName = item => {
const id =
item.get("witness_account") || item.get("committee_member_account");
return id
? ChainStore.getAccountName(id) || id
: item.get("worker")
? item.get("name")
: null;
if (item.id.startsWith("1.14")) {
// worker
let worker_account = ChainStore.getAccountName(item.worker_account);
return (
"Worker " +
item.name +
(worker_account
? " of " + worker_account
: " account " + item.worker_account)
);
} else if (item.id.startsWith("1.6.")) {
let witness_account = ChainStore.getAccountName(item.witness_account);
return (
"Witness " +
(witness_account
? witness_account
: " account " + item.witness_account)
);
} else {
let committee_member_account = ChainStore.getAccountName(
item.committee_member_account
);
return (
"Committee " +
(committee_member_account
? committee_member_account
: " account " + item.committee_member_account)
);
}
};

export const AccountUpdate = ({op, fromComponent, collapsed}) => {
Expand Down Expand Up @@ -53,13 +75,13 @@ export const AccountUpdate = ({op, fromComponent, collapsed}) => {
if (votesPlusData && votesMinusData) {
votesPlusData.forEach(item => {
if (item) {
const name = getVotesName(item);
const name = getVotesName(item.toJS());
if (name) votesPlusNames.push(name);
}
});
votesMinusData.forEach(item => {
if (item) {
const name = getVotesName(item);
const name = getVotesName(item.toJS());
if (name) votesMinusNames.push(name);
}
});
Expand Down Expand Up @@ -123,8 +145,15 @@ export const AccountUpdate = ({op, fromComponent, collapsed}) => {
}

if (memo_key) {
change.memo = {};
const _memo = _account.get("options").get("memo_key");
change.memo.keys = compareKeys([_memo], [memo_key]);
if (
change.memo.keys.minus.length == 0 &&
change.memo.keys.plus.length == 0
) {
change.memo = undefined;
}
}
}

Expand Down
58 changes: 37 additions & 21 deletions app/components/Utility/TranslateWithLinks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,24 @@ export default class TranslateWithLinks extends React.Component {
<div>
<Translate content={"proposal.votes"} />
{votes.minus.length ? (
<div>- {votes.minus.join(", ")}</div>
<div>
{"- " +
counterpart.translate(
"proposal.remove"
) +
" "}{" "}
{votes.minus.join(", ")}
</div>
) : null}
{votes.plus.length ? (
<div>+ {votes.plus.join(", ")}</div>
<div>
{"- " +
counterpart.translate(
"proposal.add"
) +
" "}{" "}
{votes.plus.join(", ")}
</div>
) : null}
</div>
);
Expand Down Expand Up @@ -297,25 +311,27 @@ export default class TranslateWithLinks extends React.Component {
</div>
</React.Fragment>
);
const memoDiv = memo && (
<div>
<Translate
content={"proposal.change_memo"}
/>
{memo.keys.plus.length > 0 && (
<div>
{" "}
+ {memo.keys.plus.join(", ")}
</div>
)}
{memo.keys.minus.length > 0 && (
<div>
{" "}
- {memo.keys.minus.join(", ")}
</div>
)}
</div>
);
const memoDiv = memo &&
(memo.keys.plus.length > 0 ||
memo.keys.minus.length > 0) && (
<div>
<Translate
content={"proposal.changes_to_memo"}
/>
{memo.keys.plus.length > 0 && (
<div>
{" "}
+ {memo.keys.plus.join(", ")}
</div>
)}
{memo.keys.minus.length > 0 && (
<div>
{" "}
- {memo.keys.minus.join(", ")}
</div>
)}
</div>
);
value = (
<div
style={{
Expand Down

0 comments on commit 5376c5b

Please sign in to comment.