Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 6752ad7

Browse files
committed
fix desktop wallet page
1 parent b06448e commit 6752ad7

File tree

2 files changed

+40
-39
lines changed

2 files changed

+40
-39
lines changed

src/common/components/rc-info/index.tsx

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,45 +34,8 @@ export const ResourceCreditsInfo = (props: any) => {
3434
const [transferAmount, setTransferAmount] = useState(0);
3535
const [customJsonAmount, setCustomJsonAmount] = useState(0);
3636

37-
useEffect(() => {
38-
findRcAccounts(account.name)
39-
.then((r) => {
40-
const outGoing = r.map((a: any) => a.delegated_rc);
41-
const delegated = outGoing[0];
42-
const formatOutGoing: any = rcFormatter(delegated);
43-
setDelegated(formatOutGoing);
44-
const availableResourceCredit: any = r.map((a: any) => Number(a.rc_manabar.current_mana));
45-
const inComing: any = r.map((a: any) => Number(a.received_delegated_rc));
46-
const formatIncoming = rcFormatter(inComing);
47-
const totalRc = Number(availableResourceCredit) + Number(inComing);
48-
setReceivedDelegation(formatIncoming);
49-
setResourceCredit(totalRc);
50-
51-
const rcOperationsCost = async () => {
52-
const rcStats: any = await getRcOperationStats();
53-
const operationCosts = rcStats.rc_stats.ops;
54-
const commentCost = operationCosts.comment_operation.avg_cost;
55-
const transferCost = operationCosts.transfer_operation.avg_cost;
56-
const voteCost = operationCosts.vote_operation.avg_cost;
57-
const customJsonOperationsCosts = operationCosts.custom_json_operation.avg_cost;
58-
59-
const commentCount: number = Math.ceil(Number(availableResourceCredit) / commentCost);
60-
const votetCount: number = Math.ceil(Number(availableResourceCredit) / voteCost);
61-
const transferCount: number = Math.ceil(Number(availableResourceCredit) / transferCost);
62-
const customJsonCount: number = Math.ceil(
63-
Number(availableResourceCredit) / customJsonOperationsCosts
64-
);
65-
setCommentAmount(commentCount);
66-
setVoteAmount(votetCount);
67-
setTransferAmount(transferCount);
68-
setCustomJsonAmount(customJsonCount);
69-
};
70-
rcOperationsCost();
71-
})
72-
.catch(console.log);
73-
}, []);
74-
7537
const showModal = () => {
38+
fetchRCData();
7639
setShowRcInfo(true);
7740
};
7841

@@ -114,6 +77,44 @@ export const ResourceCreditsInfo = (props: any) => {
11477
setShowConfirmDelete(false);
11578
};
11679

80+
const fetchRCData = () => {
81+
findRcAccounts(account.name)
82+
.then((r) => {
83+
const outGoing = r.map((a: any) => a.delegated_rc);
84+
const delegated = outGoing[0];
85+
const formatOutGoing: any = rcFormatter(delegated);
86+
setDelegated(formatOutGoing);
87+
const availableResourceCredit: any = r.map((a: any) => Number(a.rc_manabar.current_mana));
88+
const inComing: any = r.map((a: any) => Number(a.received_delegated_rc));
89+
const formatIncoming = rcFormatter(inComing);
90+
const totalRc = Number(availableResourceCredit) + Number(inComing);
91+
setReceivedDelegation(formatIncoming);
92+
setResourceCredit(totalRc);
93+
94+
const rcOperationsCost = async () => {
95+
const rcStats: any = await getRcOperationStats();
96+
const operationCosts = rcStats.rc_stats.ops;
97+
const commentCost = operationCosts.comment_operation.avg_cost;
98+
const transferCost = operationCosts.transfer_operation.avg_cost;
99+
const voteCost = operationCosts.vote_operation.avg_cost;
100+
const customJsonOperationsCosts = operationCosts.custom_json_operation.avg_cost;
101+
102+
const commentCount: number = Math.ceil(Number(availableResourceCredit) / commentCost);
103+
const votetCount: number = Math.ceil(Number(availableResourceCredit) / voteCost);
104+
const transferCount: number = Math.ceil(Number(availableResourceCredit) / transferCost);
105+
const customJsonCount: number = Math.ceil(
106+
Number(availableResourceCredit) / customJsonOperationsCosts
107+
);
108+
setCommentAmount(commentCount);
109+
setVoteAmount(votetCount);
110+
setTransferAmount(transferCount);
111+
setCustomJsonAmount(customJsonCount);
112+
};
113+
rcOperationsCost();
114+
})
115+
.catch(console.log);
116+
};
117+
117118
return (
118119
<div>
119120
<div className="cursor-pointer d-flex flex-column mb-1" onClick={showModal}>

src/common/components/wallet-hive/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export class WalletHive extends BaseComponent<Props, State> {
324324
tokenType
325325
} = this.state;
326326

327-
if (!account.__loaded) {
327+
if (!account?.__loaded) {
328328
return null;
329329
}
330330

0 commit comments

Comments
 (0)