|
|
@@ -584,11 +584,10 @@ class PageService {
|
|
|
await PageOperation.findByIdAndDelete(pageOpId);
|
|
|
}
|
|
|
|
|
|
- async resumeRenamePageOperation(user): Promise<void> {
|
|
|
+ async resumeRenamePageOperation(user: any): Promise<void> {
|
|
|
if (user == null) {
|
|
|
throw Error('Guest user cannot execute this operation');
|
|
|
}
|
|
|
- /* eslint-disable no-await-in-loop */
|
|
|
const Page = mongoose.model('Page') as unknown as PageModel;
|
|
|
|
|
|
const filter = { actionType: PageActionType.Rename, actionStage: PageActionStage.Sub };
|
|
|
@@ -599,13 +598,14 @@ class PageService {
|
|
|
}
|
|
|
|
|
|
// resume multiple rename operations almost parallelly
|
|
|
- for (const po of pageOps) {
|
|
|
+ await Promise.all(pageOps.map(async(pageOp) => {
|
|
|
+
|
|
|
const {
|
|
|
page, toPath, options,
|
|
|
- } = po;
|
|
|
+ } = pageOp;
|
|
|
|
|
|
if (toPath == null) {
|
|
|
- throw Error(`Property toPath is missing which is needed to resume renaming this page operation(${po._id})`);
|
|
|
+ throw Error(`Property toPath is missing which is needed to resume renaming this page operation(${pageOp._id})`);
|
|
|
}
|
|
|
|
|
|
const renamedPage = await Page.findOne({ _id: page._id }); // sub operation needs updated page
|
|
|
@@ -613,8 +613,8 @@ class PageService {
|
|
|
throw Error(`Renamed page(${page._id} is not found)`);
|
|
|
}
|
|
|
|
|
|
- this.renameSubOperation(page, toPath, user, options, renamedPage, po._id);
|
|
|
- }
|
|
|
+ this.renameSubOperation(page, toPath, user, options, renamedPage, pageOp._id);
|
|
|
+ }));
|
|
|
|
|
|
}
|
|
|
|