mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-23 04:10:05 +00:00
turn DownloadingToast into component to fix hook use in it
This commit is contained in:
@@ -7,12 +7,12 @@ import { fetcher } from '../utils/fetchWithSWR'
|
||||
import { getStoredToken } from '../utils/protectedRouteHandler'
|
||||
|
||||
/**
|
||||
* Generates a loading toast with file download progress support
|
||||
* @param router Next router instance, used for reloading the page
|
||||
* @param progress Current downloading and compression progress (returned by jszip metadata)
|
||||
* @returns Toast component with loading progress
|
||||
* A loading toast component with file download progress support
|
||||
* @param props
|
||||
* @param props.router Next router instance, used for reloading the page
|
||||
* @param props.progress Current downloading and compression progress (returned by jszip metadata)
|
||||
*/
|
||||
export function DownloadingToast(router: NextRouter, progress?: string) {
|
||||
export function DownloadingToast({ router, progress }: { router: NextRouter, progress?: string }) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
@@ -84,7 +84,7 @@ export async function downloadMultipleFiles({
|
||||
|
||||
// Create zip file and download it
|
||||
const b = await zip.generateAsync({ type: 'blob' }, metadata => {
|
||||
toast.loading(DownloadingToast(router, metadata.percent.toFixed(0)), {
|
||||
toast.loading(<DownloadingToast router={router} progress={metadata.percent.toFixed(0)} />, {
|
||||
id: toastId,
|
||||
})
|
||||
})
|
||||
@@ -152,7 +152,7 @@ export async function downloadTreelikeMultipleFiles({
|
||||
|
||||
// Create zip file and download it
|
||||
const b = await zip.generateAsync({ type: 'blob' }, metadata => {
|
||||
toast.loading(DownloadingToast(router, metadata.percent.toFixed(0)), {
|
||||
toast.loading(<DownloadingToast router={router} progress={metadata.percent.toFixed(0)} />, {
|
||||
id: toastId,
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user