import { Fragment } from 'react' import { PluginType } from '@janhq/core' import { ModelPlugin } from '@janhq/core/lib/plugins' import { Progress, Modal, ModalContent, Button, ModalHeader, ModalTitle, ModalTrigger, } from '@janhq/uikit' import { useAtomValue } from 'jotai' import { useDownloadState } from '@/hooks/useDownloadState' import { formatDownloadPercentage } from '@/utils/converter' import { downloadingModelsAtom } from '@/helpers/atoms/Model.atom' import { pluginManager } from '@/plugin' export default function DownloadingState() { const { downloadStates } = useDownloadState() const models = useAtomValue(downloadingModelsAtom) const totalCurrentProgress = downloadStates .map((a) => a.size.transferred + a.size.transferred) .reduce((partialSum, a) => partialSum + a, 0) const totalSize = downloadStates .map((a) => a.size.total + a.size.total) .reduce((partialSum, a) => partialSum + a, 0) const totalPercentage = ((totalCurrentProgress / totalSize) * 100).toFixed(2) return ( {downloadStates?.length > 0 && (
Downloading model {downloadStates.map((item, i) => { return (

{item?.fileName}

{formatDownloadPercentage(item?.percent)}
) })}
)}
) }