fix(views/table): bulk actions sometimes not working

This commit is contained in:
Elian Doran
2025-07-19 12:44:55 +03:00
parent e2c8443778
commit 5d619131ec
3 changed files with 20 additions and 15 deletions

View File

@@ -3,7 +3,7 @@ import becca from "../../becca/becca.js";
import bulkActionService from "../../services/bulk_actions.js";
function execute(req: Request) {
const { noteIds, includeDescendants } = req.body;
const { noteIds, includeDescendants, actions } = req.body;
if (!Array.isArray(noteIds)) {
throw new Error("noteIds must be an array");
}
@@ -12,7 +12,16 @@ function execute(req: Request) {
const bulkActionNote = becca.getNoteOrThrow("_bulkAction");
bulkActionService.executeActionsFromNote(bulkActionNote, affectedNoteIds);
if (actions && actions.length > 0) {
for (const action of actions) {
if (!action.name) {
throw new Error("Action must have a name");
}
}
bulkActionService.executeActions(actions, affectedNoteIds);
} else {
bulkActionService.executeActionsFromNote(bulkActionNote, affectedNoteIds);
}
}
function getAffectedNoteCount(req: Request) {