|
22 | 22 | import { emit } from '@nextcloud/event-bus' |
23 | 23 | import { Permission, Node, View, FileAction, FileType } from '@nextcloud/files' |
24 | 24 | import { showInfo } from '@nextcloud/dialogs' |
25 | | -import { translate as t, translatePlural as n } from '@nextcloud/l10n' |
| 25 | +import { translate as t } from '@nextcloud/l10n' |
26 | 26 | import axios from '@nextcloud/axios' |
27 | 27 |
|
28 | 28 | import CloseSvg from '@mdi/svg/svg/close.svg?raw' |
29 | 29 | import NetworkOffSvg from '@mdi/svg/svg/network-off.svg?raw' |
30 | 30 | import TrashCanSvg from '@mdi/svg/svg/trash-can.svg?raw' |
31 | 31 |
|
32 | 32 | import logger from '../logger.js' |
| 33 | +import PQueue from 'p-queue' |
33 | 34 |
|
34 | 35 | const canUnshareOnly = (nodes: Node[]) => { |
35 | 36 | return nodes.every(node => node.attributes['is-mount-root'] === true |
@@ -119,6 +120,8 @@ const displayName = (nodes: Node[], view: View) => { |
119 | 120 | return t('files', 'Delete') |
120 | 121 | } |
121 | 122 |
|
| 123 | +const queue = new PQueue({ concurrency: 1 }) |
| 124 | + |
122 | 125 | export const action = new FileAction({ |
123 | 126 | id: 'delete', |
124 | 127 | displayName, |
@@ -183,7 +186,19 @@ export const action = new FileAction({ |
183 | 186 | return Promise.all(nodes.map(() => false)) |
184 | 187 | } |
185 | 188 |
|
186 | | - return Promise.all(nodes.map(node => this.exec(node, view, dir))) |
| 189 | + // Map each node to a promise that resolves with the result of exec(node) |
| 190 | + const promises = nodes.map(node => { |
| 191 | + // Create a promise that resolves with the result of exec(node) |
| 192 | + const promise = new Promise<boolean>(resolve => { |
| 193 | + queue.add(async () => { |
| 194 | + const result = await this.exec(node, view, dir) |
| 195 | + resolve(result !== null ? result : false) |
| 196 | + }) |
| 197 | + }) |
| 198 | + return promise |
| 199 | + }) |
| 200 | + |
| 201 | + return Promise.all(promises) |
187 | 202 | }, |
188 | 203 |
|
189 | 204 | order: 100, |
|
0 commit comments