core: update hook usage

This commit is contained in:
undefined committed 2022-09-23 20:10:36 +08:00
1 parent ab933bc9d5
commit 757b5e6bc1
27 files changed
+63 -64

No files matched your search

+3 -3
View File
@@ -115,7 +115,7 @@ export class ProblemModel {
title, tag, hidden, assign, nSubmit: 0, nAccept: 0, sort: sortable(pid || `P${docId}`),
};
if (pid) args.pid = pid;
await bus.serial('problem/before-add', domainId, content, owner, docId, args);
await bus.parallel('problem/before-add', domainId, content, owner, docId, args);
const result = await document.add(domainId, content, owner, document.TYPE_PROBLEM, docId, null, null, args);
args.content = content;
args.owner = owner;
@@ -193,7 +193,7 @@ export class ProblemModel {
} else if ($set.pid) {
$set.sort = sortable($set.pid);
}
await bus.serial('problem/before-edit', $set);
await bus.parallel('problem/before-edit', $set);
const result = await document.set(domainId, document.TYPE_PROBLEM, _id, $set, delpid ? { pid: '' } : undefined);
await bus.emit('problem/edit', result);
return result;
@@ -230,7 +230,7 @@ export class ProblemModel {
}
static async del(domainId: string, docId: number) {
await bus.serial('problem/before-del', domainId, docId);
await bus.parallel('problem/before-del', domainId, docId);
const res = await Promise.all([
document.deleteOne(domainId, document.TYPE_PROBLEM, docId),
document.deleteMultiStatus(domainId, document.TYPE_PROBLEM, { docId }),