mirror of
https://github.com/transmission/transmission
synced 2024-12-22 07:42:37 +00:00
Update torrent-row.js (#7245)
This commit is contained in:
parent
384b265033
commit
a1befba4d8
1 changed files with 13 additions and 8 deletions
|
@ -45,7 +45,8 @@ const TorrentRendererHelper = {
|
||||||
getProgressInfo: (controller, t) => {
|
getProgressInfo: (controller, t) => {
|
||||||
const status = t.getStatus();
|
const status = t.getStatus();
|
||||||
const classList = ['torrent-progress-bar'];
|
const classList = ['torrent-progress-bar'];
|
||||||
let percent = null;
|
let percent = 100;
|
||||||
|
let ratio = null;
|
||||||
|
|
||||||
if (status === Torrent._StatusStopped) {
|
if (status === Torrent._StatusStopped) {
|
||||||
classList.push('paused');
|
classList.push('paused');
|
||||||
|
@ -62,11 +63,13 @@ const TorrentRendererHelper = {
|
||||||
percent = t.getPercentDone() * 100;
|
percent = t.getPercentDone() * 100;
|
||||||
} else {
|
} else {
|
||||||
classList.push('seed');
|
classList.push('seed');
|
||||||
const seed_ratio_limit = t.seedRatioLimit(controller);
|
if (status !== Torrent._StatusStopped) {
|
||||||
percent =
|
const seed_ratio_limit = t.seedRatioLimit(controller);
|
||||||
seed_ratio_limit > 0
|
ratio =
|
||||||
? (t.getUploadRatio() * 100) / seed_ratio_limit
|
seed_ratio_limit > 0
|
||||||
: 100;
|
? (t.getUploadRatio() * 100) / seed_ratio_limit
|
||||||
|
: 100;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (t.isQueued()) {
|
if (t.isQueued()) {
|
||||||
classList.push('queued');
|
classList.push('queued');
|
||||||
|
@ -75,15 +78,17 @@ const TorrentRendererHelper = {
|
||||||
return {
|
return {
|
||||||
classList,
|
classList,
|
||||||
percent,
|
percent,
|
||||||
|
ratio,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
renderProgressbar: (controller, t, progressbar) => {
|
renderProgressbar: (controller, t, progressbar) => {
|
||||||
const info = TorrentRendererHelper.getProgressInfo(controller, t);
|
const info = TorrentRendererHelper.getProgressInfo(controller, t);
|
||||||
const pct_str = `${Formatter.percentString(info.percent, 2)}%`;
|
const percent = Math.min(info.ratio || info.percent, 100);
|
||||||
|
const pct_str = `${Formatter.percentString(percent, 2)}%`;
|
||||||
progressbar.className = info.classList.join(' ');
|
progressbar.className = info.classList.join(' ');
|
||||||
progressbar.style.setProperty('--progress', pct_str);
|
progressbar.style.setProperty('--progress', pct_str);
|
||||||
progressbar.dataset.progress = pct_str;
|
progressbar.dataset.progress = info.ratio ? '100%' : pct_str;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue