Skip to content

Commit

Permalink
Bug Fix and Enhancement: Volume Size Calculation (#1875)
Browse files Browse the repository at this point in the history
* Remove redundant check for undefined volume sizes

* Refactor volume size calculation to handle null or undefined values explicitly
  • Loading branch information
GiselleNessi authored Mar 11, 2024
1 parent 6d29218 commit 63236dc
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ export const VolumesList = ({ dnp }: { dnp: InstalledPackageDetailData }) => {
return null;
}

const isTotalVolumeSizeIllDefined = volumes.some(v => !v.size);

const totalVolumeSize = volumes.reduce(
(total, vol) => total + (vol.size || 0),
(total, vol) => (vol.size != null ? total + vol.size : total),
0
);

Expand All @@ -104,7 +102,7 @@ export const VolumesList = ({ dnp }: { dnp: InstalledPackageDetailData }) => {
</span>
</span>
<span>
{isTotalVolumeSizeIllDefined ? "-" : prettyBytes(totalVolumeSize)}
{prettyBytes(totalVolumeSize)}
</span>

<BsTrash
Expand Down

0 comments on commit 63236dc

Please sign in to comment.