'init'
This commit is contained in:
13
app/providers/TransportProvider/useDownloadStatus.ts
Normal file
13
app/providers/TransportProvider/useDownloadStatus.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { useContext } from "react";
|
||||
import { TransportContext } from "./TransportProvider";
|
||||
|
||||
export function useDownloadStatus(tag: string) {
|
||||
const context = useContext(TransportContext);
|
||||
if (!context) {
|
||||
throw new Error("useDownloadStatus must be used within a TransportProvider");
|
||||
}
|
||||
const { downloading } = context;
|
||||
let downloadState = downloading.find(u => u.id === tag);
|
||||
|
||||
return downloadState ? downloadState.progress : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user