From e1f10b76bbdb3a867ee98504be3dbfa742065b8b Mon Sep 17 00:00:00 2001 From: Anton Shepilov Date: Tue, 27 Feb 2024 10:10:07 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20bug=20with=20react=20hooks?= =?UTF-8?q?=20in=20disk=20usage=20component=20(#378)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/views/client/common/disk-usage.tsx | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/tdrive/frontend/src/app/views/client/common/disk-usage.tsx b/tdrive/frontend/src/app/views/client/common/disk-usage.tsx index a1d90a5da..554e07776 100644 --- a/tdrive/frontend/src/app/views/client/common/disk-usage.tsx +++ b/tdrive/frontend/src/app/views/client/common/disk-usage.tsx @@ -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 ( <>