Skip to content

Commit

Permalink
πŸ› Fix bug with react hooks in disk usage component (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
shepilov authored Feb 27, 2024
1 parent a49ee3f commit e1f10b7
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions tdrive/frontend/src/app/views/client/common/disk-usage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ const DiskUsage = () => {
const [usedBytes, setUsedBytes] = useState(0);
const [totalBytes, setTotalBytes] = useState(0);

if (FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_USER_QUOTA)) {
const { quota } = useUserQuota()
useEffect(() => {
setUsed(Math.round(quota.used / quota.total * 100))
setUsedBytes(quota.used);
setTotalBytes(quota.total);
}, [quota]);
} else if (viewId) {
const { item } = useDriveItem(viewId);
useEffect(() => {
setUsedBytes(item?.size || 0);
}, [viewId, item])
}
const { quota } = useUserQuota()
useEffect(() => {
setUsed(Math.round(quota.used / quota.total * 100))
setUsedBytes(quota.used);
setTotalBytes(quota.total);
}, [quota]);

const { item } = useDriveItem(viewId || "root");
useEffect(() => {
setUsedBytes(item?.size || 0);
}, [viewId, item])

return (
<>
Expand Down

0 comments on commit e1f10b7

Please sign in to comment.