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

pull/827/head
TheCatLady 4 years ago committed by GitHub
parent b116281196
commit c97c96a30c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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>

Loading…
Cancel
Save