Fix display of size values in web interface #2703
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The web interface rounded large number values down using
Math.floor()
, causing the web interface to display faulty torrent/download sizes.For example, a torrent of size 1,92 GB (915 pieces @ 2,1 MB) was shown as "1GB".
After about half the download was done, the UI showed "1GB of 1GB (55%)", which is rather irritating.
This fix removes the
Math.floor()
and adds fractions to the larger size values.I also added
maximumFractionDigits
to the download speed formatters, because2.234MB/s
kinda looks weird.Note: Is there a reason Transmission uses SI notation for file sizes?
For one, the display of the piece size is affected, as the piece size in my example is 2097152 bytes, which is 2MiB, but 2.1MB, which I find to look weird.
Also, the file size displayed by the Transmission UI is not the same size the file actually occupies on the disc, which may also be confusing.