diff --git a/providers/Downloads/hooks/useDownloadOperations.ts b/providers/Downloads/hooks/useDownloadOperations.ts index 73382e2d..1cf0e51c 100644 --- a/providers/Downloads/hooks/useDownloadOperations.ts +++ b/providers/Downloads/hooks/useDownloadOperations.ts @@ -6,6 +6,7 @@ import { File, Paths } from "expo-file-system"; import type { MutableRefObject } from "react"; import { useCallback } from "react"; import { useTranslation } from "react-i18next"; +import DeviceInfo from "react-native-device-info"; import { toast } from "sonner-native"; import type { Bitrate } from "@/components/BitrateSelector"; import useImageStorage from "@/hooks/useImageStorage"; @@ -286,11 +287,25 @@ export function useDownloadOperations({ const appSizeUsage = useCallback(async () => { const totalSize = calculateTotalDownloadedSize(); - return { - total: 0, - remaining: 0, - appSize: totalSize, - }; + try { + const [freeDiskStorage, totalDiskCapacity] = await Promise.all([ + DeviceInfo.getFreeDiskStorage(), + DeviceInfo.getTotalDiskCapacity(), + ]); + + return { + total: totalDiskCapacity, + remaining: freeDiskStorage, + appSize: totalSize, + }; + } catch (error) { + console.error("Failed to get disk storage info:", error); + return { + total: 0, + remaining: 0, + appSize: totalSize, + }; + } }, []); return {