13 lines
463 B
TypeScript
13 lines
463 B
TypeScript
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;
|
|
} |