Skip to content

Commit

Permalink
fix: handle null value percentage + set as null if percentage can't b…
Browse files Browse the repository at this point in the history
…e calculated (#47)
  • Loading branch information
slazor authored Mar 3, 2022
1 parent 973a42a commit f7832d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/main/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ class Session {
.reduce((previous, current) => previous + current.total, 0);

for (const key in this.aggregated[type]) {
this.aggregated[type][key].percent = Number((this.aggregated[type][key].total / typeTotal) * 100);
if (this.aggregated[type][key].total > 0 && typeTotal > 0) {
this.aggregated[type][key].percent = Number((this.aggregated[type][key].total / typeTotal) * 100);
} else {
this.aggregated[type][key].percent = null;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/hunting/views/loot-view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const LootView = () => {
<td>{row.key}</td>
<td>{row.count.toLocaleString()}</td>
<td><span className="sum">{row.total.toFixed(2)}</span> PED</td>
<td>{row.percent.toFixed(2)} %</td>
<td>{row.percent ? `${row.percent.toFixed(2)} %` : '--' }</td>
</tr>
))}
</Table>
Expand Down

0 comments on commit f7832d2

Please sign in to comment.