From 63bc806a069f080370ca0807c8d0d0a8a66f5ed3 Mon Sep 17 00:00:00 2001 From: lance chant <13349722+lancechant@users.noreply.github.com> Date: Mon, 2 Jun 2025 14:13:13 +0200 Subject: [PATCH] fix: made tv os compile (#721) --- providers/DownloadProvider.tsx | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/providers/DownloadProvider.tsx b/providers/DownloadProvider.tsx index 3e3c215e..c1ea7b6f 100644 --- a/providers/DownloadProvider.tsx +++ b/providers/DownloadProvider.tsx @@ -842,12 +842,39 @@ export function DownloadProvider({ children }: { children: React.ReactNode }) { } export function useDownload() { + if (Platform.isTV) { + // Since tv doesn't do downloads, just return no-op functions for everything + return { + processes: [], + startBackgroundDownload: useCallback( + async ( + _url: string, + _item: BaseItemDto, + _mediaSource: MediaSourceInfo, + _maxBitrate?: Bitrate, + ) => {}, + [], + ), + downloadedFiles: [], + deleteAllFiles: async (): Promise => {}, + deleteFile: async (id: string): Promise => {}, + deleteItems: async (items: BaseItemDto[]) => {}, + saveDownloadedItemInfo: (item: BaseItemDto, size?: number) => {}, + removeProcess: (id: string) => {}, + setProcesses: () => {}, + startDownload: async (_process: JobStatus): Promise => {}, + getDownloadedItem: (itemId: string) => {}, + deleteFileByType: async (_type: BaseItemDto["Type"]) => {}, + appSizeUsage: async () => 0, + getDownloadedItemSize: (itemId: string) => {}, + APP_CACHE_DOWNLOAD_DIRECTORY: "", + cleanCacheDirectory: async (): Promise => {}, + }; + } + const context = useContext(DownloadContext); if (context === null) { throw new Error("useDownload must be used within a DownloadProvider"); } - if (Platform.isTV) { - throw new Error("useDownload is not supported on TVOS"); - } return context; }