Files
desktop/app/providers/TransportProvider/useUploadStatus.ts
rosetta 83f38dc63f 'init'
2026-01-30 05:01:05 +02:00

17 lines
664 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useContext } from "react";
import { TransportContext } from "./TransportProvider";
/**
* Хук для получения статуса загрузки файла по его upid
* @returns Функцию для получения статуса загрузки файла по его upid
*/
export function useUploadStatus(upid: string) {
const context = useContext(TransportContext);
if (!context) {
throw new Error("useUploadStatus must be used within a TransportProvider");
}
const { uploading } = context;
let uploadState = uploading.find(u => u.id === upid);
return uploadState ? uploadState.progress : 0;
}