diff --git a/src/bitrate.js b/src/bitrate.js
index 098a4b5..63a024d 100644
--- a/src/bitrate.js
+++ b/src/bitrate.js
@@ -26,17 +26,22 @@ export function convertedRate(bitrate) {
}
}
-export function formatBitrate(bitrate) {
- const [rate, unit] = convertedRate(bitrate);
+function places(n) {
let places = 2;
- if (rate >= 100) {
+ if (n >= 100) {
places = 0;
- } else if (rate >= 10) {
+ } else if (n >= 10) {
places = 1;
- } else if (rate == 0) {
+ }
+ if (n.toFixed(places) === (0).toFixed(places)) {
places = 0;
}
- return `${rate.toFixed(places)} ${unit}`;
+ return places;
+}
+
+export function formatBitrate(bitrate) {
+ const [rate, unit] = convertedRate(bitrate);
+ return `${rate.toFixed(places(rate))} ${unit}`;
}
export function formatAmount(amount) {
@@ -47,13 +52,5 @@ export function formatAmount(amount) {
"B/s": "bytes"
};
const [rate, unit] = convertedRate(amount);
- let places = 2;
- if (rate >= 100) {
- places = 0;
- } else if (rate >= 10) {
- places = 1;
- } else if (rate == 0) {
- places = 0;
- }
- return `${rate.toFixed(places)} ${units[unit]}`;
+ return `${rate.toFixed(places(rate))} ${units[unit]}`;
}
diff --git a/src/ui/torrent_details.js b/src/ui/torrent_details.js
index 1d52da8..748065c 100644
--- a/src/ui/torrent_details.js
+++ b/src/ui/torrent_details.js
@@ -332,7 +332,15 @@ class TorrentDetails extends Component {
selection.forEach(id => ws_send("REMOVE_RESOURCE", { id }));
}}
>Remove selected torrents
- Remove selected torrents and delete files
+ {
+ dispatch(selectTorrent(selection, SUBTRACT));
+ selection.forEach(id => ws_send("REMOVE_RESOURCE", {
+ id,
+ artifacts: true
+ }));
+ }}
+ >Remove selected torrents and delete files