fix(frontend): fix possible division by zero in download status (#839)

This commit is contained in:
TheCatLady
2021-02-03 18:42:24 -05:00
committed by GitHub
parent b116281196
commit c97c96a30c

View File

@@ -21,20 +21,26 @@ const DownloadBlock: React.FC<DownloadBlockProps> = ({
<div <div
className="h-8 transition-all duration-200 ease-in-out bg-indigo-600" className="h-8 transition-all duration-200 ease-in-out bg-indigo-600"
style={{ style={{
width: `${Math.round( width: `${
((downloadItem.size - downloadItem.sizeLeft) / downloadItem.size
downloadItem.size) * ? Math.round(
100 ((downloadItem.size - downloadItem.sizeLeft) /
)}%`, downloadItem.size) *
100
)
: 0
}%`,
}} }}
/> />
<div className="absolute inset-0 flex items-center justify-center w-full h-6 text-xs"> <div className="absolute inset-0 flex items-center justify-center w-full h-6 text-xs">
<span> <span>
{Math.round( {downloadItem.size
((downloadItem.size - downloadItem.sizeLeft) / ? Math.round(
downloadItem.size) * ((downloadItem.size - downloadItem.sizeLeft) /
100 downloadItem.size) *
)} 100
)
: 0}
% %
</span> </span>
</div> </div>