mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-02-26 05:52:34 +00:00
fix: load active downloads on app open
This commit is contained in:
@@ -34,6 +34,14 @@ async function cancelDownload(id: string): Promise<void> {
|
||||
return HlsDownloaderModule.cancelDownload(id);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns A list of active downloads.
|
||||
*/
|
||||
async function getActiveDownloads(): Promise<DownloadInfo[]> {
|
||||
return HlsDownloaderModule.getActiveDownloads();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to download progress events.
|
||||
* @param listener A callback invoked with progress updates.
|
||||
@@ -104,4 +112,5 @@ export {
|
||||
addProgressListener,
|
||||
HlsDownloaderModule,
|
||||
cancelDownload,
|
||||
getActiveDownloads,
|
||||
};
|
||||
|
||||
@@ -73,6 +73,18 @@ public class HlsDownloaderModule: Module {
|
||||
|
||||
Events("onProgress", "onError", "onComplete")
|
||||
|
||||
Function("getActiveDownloads") { () -> [[String: Any]] in
|
||||
return activeDownloads.map { (taskId, downloadInfo) in
|
||||
return [
|
||||
"id": downloadInfo.delegate.providedId,
|
||||
"state": "DOWNLOADING",
|
||||
"metadata": downloadInfo.metadata,
|
||||
"startTime": downloadInfo.startTime,
|
||||
"taskId": taskId,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Function("downloadHLSAsset") {
|
||||
(providedId: String, url: String, metadata: [String: Any]?) -> Void in
|
||||
let startTime = Date().timeIntervalSince1970
|
||||
|
||||
Reference in New Issue
Block a user