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
className="h-8 transition-all duration-200 ease-in-out bg-indigo-600"
style={{
width: `${Math.round(
((downloadItem.size - downloadItem.sizeLeft) /
downloadItem.size) *
100
)}%`,
width: `${
downloadItem.size
? Math.round(
((downloadItem.size - downloadItem.sizeLeft) /
downloadItem.size) *
100
)
: 0
}%`,
}}
/>
<div className="absolute inset-0 flex items-center justify-center w-full h-6 text-xs">
<span>
{Math.round(
((downloadItem.size - downloadItem.sizeLeft) /
downloadItem.size) *
100
)}
{downloadItem.size
? Math.round(
((downloadItem.size - downloadItem.sizeLeft) /
downloadItem.size) *
100
)
: 0}
%
</span>
</div>

Loading…
Cancel
Save