chore: fix downloads
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { FilesController } from '@/Controllers/FilesController'
|
import { FilesController } from '@/Controllers/FilesController'
|
||||||
import { NoPreviewIllustration } from '@standardnotes/icons'
|
import { NoPreviewIllustration } from '@standardnotes/icons'
|
||||||
import { FileItem } from '@standardnotes/snjs'
|
import { FileItem } from '@standardnotes/snjs'
|
||||||
|
import { FileItemActionType } from '../AttachedFilesPopover/PopoverFileItemAction'
|
||||||
import Button from '../Button/Button'
|
import Button from '../Button/Button'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -32,7 +33,14 @@ const FilePreviewError = ({ file, filesController, isFilePreviewable, tryAgainCa
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
filesController.downloadFile(file).catch(console.error)
|
filesController
|
||||||
|
.handleFileAction({
|
||||||
|
type: FileItemActionType.DownloadFile,
|
||||||
|
payload: {
|
||||||
|
file,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Download
|
Download
|
||||||
@@ -47,7 +55,12 @@ const FilePreviewError = ({ file, filesController, isFilePreviewable, tryAgainCa
|
|||||||
<Button
|
<Button
|
||||||
primary
|
primary
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
filesController.downloadFile(file).catch(console.error)
|
filesController
|
||||||
|
.handleFileAction({
|
||||||
|
type: FileItemActionType.DownloadFile,
|
||||||
|
payload: { file },
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Download
|
Download
|
||||||
|
|||||||
@@ -498,6 +498,15 @@ export class FilesController extends AbstractViewController<FilesControllerEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
downloadFiles = async (files: FileItem[]) => {
|
downloadFiles = async (files: FileItem[]) => {
|
||||||
await Promise.all(files.map((file) => this.downloadFile(file)))
|
await Promise.all(
|
||||||
|
files.map((file) =>
|
||||||
|
this.handleFileAction({
|
||||||
|
type: FileItemActionType.DownloadFile,
|
||||||
|
payload: {
|
||||||
|
file,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user