Files
rustfs-console/lib/feedback/dialog-action.js
T
2026-04-27 09:08:47 +08:00

28 lines
531 B
JavaScript

export async function runDialogAction({ dialogId, pendingIds, setPendingIds, action, close, onError }) {
if (!action) {
close()
return true
}
if (pendingIds.has(dialogId)) {
return false
}
pendingIds.add(dialogId)
setPendingIds(new Set(pendingIds))
try {
const result = await action()
if (result !== false) {
close()
}
return true
} catch (error) {
onError?.(error)
return false
} finally {
pendingIds.delete(dialogId)
setPendingIds(new Set(pendingIds))
}
}