update function names and comments according to upstream

This commit is contained in:
myl7
2021-12-16 21:57:04 +08:00
parent afcd6abd0e
commit f550a08e37
2 changed files with 17 additions and 8 deletions
+6 -4
View File
@@ -12,7 +12,9 @@ import dynamic from 'next/dynamic'
import { getExtension, getFileIcon, hasKey } from '../utils/getFileIcon'
import { extensions, preview } from '../utils/getPreviewType'
import { getBaseUrl, treeList, downloadMultipleFiles, useProtectedSWRInfinite, saveTreeFiles } from '../utils/tools'
import {
getBaseUrl, traverseFolder, downloadMultipleFiles, useProtectedSWRInfinite, downloadTreelikeMultipleFiles
} from '../utils/tools'
import { VideoPreview } from './previews/VideoPreview'
import { AudioPreview } from './previews/AudioPreview'
@@ -305,7 +307,7 @@ const FileListing: FunctionComponent<{ query?: ParsedUrlQuery }> = ({ query }) =
// Folder recursive download
const handleFolderDownload = (path: string, id: string, name?: string) => () => {
const files = (async function* () {
for await (const { meta: c, path: p, isFolder } of treeList(path)) {
for await (const { meta: c, path: p, isFolder } of traverseFolder(path)) {
yield {
name: c?.name,
url: c ? c['@microsoft.graph.downloadUrl'] : undefined,
@@ -315,8 +317,8 @@ const FileListing: FunctionComponent<{ query?: ParsedUrlQuery }> = ({ query }) =
}
})()
setFolderGenerating({ ...folderGenerating, [id]: true })
const toastId = toast.loading('Downloading folder. This may be slow...')
saveTreeFiles(files, name).then(() => {
const toastId = toast.loading('Downloading folder. Refresh to cancel, this may take some time...')
downloadTreelikeMultipleFiles(files, name).then(() => {
setFolderGenerating({ ...folderGenerating, [id]: false })
toast.dismiss(toastId)
toast.success('Finished to download folder.')