refactor: move file download logic

pull/37/head
Varun Patil 2022-09-12 15:45:09 -07:00
parent 4f8156874d
commit 3f3e83c13a
2 changed files with 19 additions and 9 deletions

View File

@ -851,15 +851,11 @@ export default {
await this.deleteFromViewWithAnimation(delIds, updatedDays);
},
/** Download the selected files */
async downloadSelection() {
if (this.selection.size === 0) {
return;
}
// Get files to download
const fileInfos = await dav.getFiles([...this.selection].map(p => p.fileid));
await dav.downloadFiles(fileInfos.map(f => f.filename));
/**
* Download the currently selected files
*/
downloadSelection() {
dav.downloadFilesByIds([...this.selection].map(p => p.fileid));
},
/**

View File

@ -171,3 +171,17 @@ export async function deleteFile(path) {
)
})
}
/**
* Download the files given by the fileIds
* @param {number[]} fileIds
*/
export async function downloadFilesByIds(fileIds) {
if (fileIds.length === 0) {
return;
}
// Get files to download
const fileInfos = await getFiles(fileIds);
await downloadFiles(fileInfos.map(f => f.filename));
}