Skip to content

Commit 4f5420f

Browse files
committed
feat: send the ws ItemOpFeedbackEvent move after the transaction
1 parent f4db3e2 commit 4f5420f

1 file changed

Lines changed: 25 additions & 20 deletions

File tree

src/services/item/controller.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -275,26 +275,31 @@ const plugin: FastifyPluginAsync = async (fastify) => {
275275
const repositories = buildRepositories(manager);
276276
const items = await itemService.moveMany(member, repositories, ids, parentId);
277277
await actionItemService.postManyMoveAction(request, reply, repositories, items);
278-
if (member) {
279-
websockets.publish(
280-
memberItemsTopic,
281-
member.id,
282-
ItemOpFeedbackEvent('move', ids, {
283-
data: Object.fromEntries(items.map((i) => [i.id, i])),
284-
errors: [],
285-
}),
286-
);
287-
}
288-
}).catch((e) => {
289-
log.error(e);
290-
if (member) {
291-
websockets.publish(
292-
memberItemsTopic,
293-
member.id,
294-
ItemOpFeedbackEvent('move', ids, { error: e }),
295-
);
296-
}
297-
});
278+
return items;
279+
})
280+
// TODO: do the same for the copy and the others ?
281+
.then((items) => {
282+
if (member) {
283+
websockets.publish(
284+
memberItemsTopic,
285+
member.id,
286+
ItemOpFeedbackEvent('move', ids, {
287+
data: Object.fromEntries(items.map((i) => [i.id, i])),
288+
errors: [],
289+
}),
290+
);
291+
}
292+
})
293+
.catch((e) => {
294+
log.error(e);
295+
if (member) {
296+
websockets.publish(
297+
memberItemsTopic,
298+
member.id,
299+
ItemOpFeedbackEvent('move', ids, { error: e }),
300+
);
301+
}
302+
});
298303
reply.status(StatusCodes.ACCEPTED);
299304
return ids;
300305
},

0 commit comments

Comments
 (0)