From 8924dd2ce8dbbce3a4c9a3f15d05b18edae39673 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Mon, 17 Feb 2025 14:19:29 +0100 Subject: [PATCH] chore: removed code --- modules/hls-downloader/index.ts | 9 ------- .../ios/HlsDownloaderModule.swift | 24 ------------------- providers/NativeDownloadProvider.tsx | 24 ------------------- 3 files changed, 57 deletions(-) diff --git a/modules/hls-downloader/index.ts b/modules/hls-downloader/index.ts index 3237935c..8859e48b 100644 --- a/modules/hls-downloader/index.ts +++ b/modules/hls-downloader/index.ts @@ -25,14 +25,6 @@ function downloadHLSAsset( HlsDownloaderModule.downloadHLSAsset(id, url, metadata); } -/** - * Checks for existing downloads. - * Returns an array of downloads with additional fields: - */ -async function checkForExistingDownloads(): Promise { - return HlsDownloaderModule.checkForExistingDownloads(); -} - /** * Cancels an ongoing download. * @param id - The unique identifier for the download. @@ -105,7 +97,6 @@ function useDownloadError(): string | null { export { downloadHLSAsset, - checkForExistingDownloads, useDownloadError, useDownloadProgress, addCompleteListener, diff --git a/modules/hls-downloader/ios/HlsDownloaderModule.swift b/modules/hls-downloader/ios/HlsDownloaderModule.swift index 80b856eb..86d41c2c 100644 --- a/modules/hls-downloader/ios/HlsDownloaderModule.swift +++ b/modules/hls-downloader/ios/HlsDownloaderModule.swift @@ -144,30 +144,6 @@ public class HlsDownloaderModule: Module { } } - Function("checkForExistingDownloads") { - () -> [[String: Any]] in - var downloads: [[String: Any]] = [] - for (id, pair) in self.activeDownloads { - let task = pair.task - let delegate = pair.delegate - let metadata = pair.metadata - let startTime = pair.startTime - let downloaded = delegate.downloadedSeconds - let total = delegate.totalSeconds - let progress = total > 0 ? downloaded / total : 0 - downloads.append([ - "id": delegate.providedId.isEmpty ? String(id) : delegate.providedId, - "progress": progress, - "secondsDownloaded": downloaded, - "secondsTotal": total, - "state": self.mappedState(for: task), - "metadata": metadata, - "startTime": startTime, - ]) - } - return downloads - } - Function("cancelDownload") { (providedId: String) -> Void in guard let entry = self.activeDownloads.first(where: { $0.value.delegate.providedId == providedId } diff --git a/providers/NativeDownloadProvider.tsx b/providers/NativeDownloadProvider.tsx index 4d2762e3..fa45a162 100644 --- a/providers/NativeDownloadProvider.tsx +++ b/providers/NativeDownloadProvider.tsx @@ -3,7 +3,6 @@ import { addCompleteListener, addErrorListener, addProgressListener, - checkForExistingDownloads, downloadHLSAsset, cancelDownload, } from "@/modules/hls-downloader"; @@ -145,29 +144,6 @@ export const NativeDownloadProvider: React.FC<{ }); useEffect(() => { - // const initializeDownloads = async () => { - // const hlsDownloads = await checkForExistingDownloads(); - // const hlsDownloadStates = hlsDownloads.reduce( - // (acc, download) => ({ - // ...acc, - // [download.id]: { - // id: download.id, - // progress: download.progress, - // state: download.state, - // secondsDownloaded: download.secondsDownloaded, - // secondsTotal: download.secondsTotal, - // metadata: download.metadata, - // startTime: download?.startTime, - // }, - // }), - // {} - // ); - - // setDownloads({ ...hlsDownloadStates }); - // }; - - // initializeDownloads(); - const progressListener = addProgressListener((download) => { if (!download.metadata) throw new Error("No metadata found in download");