Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions apps/files/src/actions/deleteAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import TrashCan from '@mdi/svg/svg/trash-can.svg?raw'
import { registerFileAction, FileAction } from '../services/FileAction.ts'
import logger from '../logger.js'
import type { Navigation } from '../services/Navigation.ts'
import { encodePath } from '@nextcloud/paths';
import { encodePath } from '@nextcloud/paths'
import PQueue from 'p-queue'

const queue = new PQueue({ concurrency: 1 })
registerFileAction(new FileAction({
id: 'delete',
displayName(nodes: Node[], view: Navigation) {
Expand Down Expand Up @@ -63,7 +65,19 @@ registerFileAction(new FileAction({
}
},
async execBatch(nodes: Node[], view: Navigation, dir: string) {
return Promise.all(nodes.map(node => this.exec(node, view, dir)))
// Map each node to a promise that resolves with the result of exec(node)
const promises = nodes.map(node => {
// Create a promise that resolves with the result of exec(node)
const promise = new Promise<boolean>(resolve => {
queue.add(async () => {
const result = await this.exec(node, view, dir)
resolve(result !== null ? result : false)
})
})
return promise
})

return Promise.all(promises)
},

order: 100,
Expand Down