diff --git a/backend/src/controllers/page.ts b/backend/src/controllers/page.ts index a87e055..d0f800f 100644 --- a/backend/src/controllers/page.ts +++ b/backend/src/controllers/page.ts @@ -7,7 +7,13 @@ export const create = transactionHandler( async (req: Request, res: Response): Promise => { const page = await pageService.create(req.body.page); const pages = await pageService.readAll(); - req.app.get('io').of('/pageList').emit('PageListUpdate', pages); + req.app + .get('io') + .of('/pageList') + .emit('PageListUpdate', { + currentPageId: (req.session as any).pageId, + pages, + }); res.status(StatusCode.CREATED).json({ page, pages }); }, ); @@ -25,7 +31,13 @@ export const readAll = async (req: Request, res: Response): Promise => { export const update = async (req: Request, res: Response): Promise => { const page = await pageService.update(req.params.pageId, req.body.page); const pages = await pageService.readAll(); - req.app.get('io').of('/pageList').emit('PageListUpdate', pages); + req.app + .get('io') + .of('/pageList') + .emit('PageListUpdate', { + currentPageId: (req.session as any).pageId, + pages, + }); res.status(StatusCode.OK).json({ page }); }; @@ -33,7 +45,13 @@ export const deleteOne = transactionHandler( async (req: Request, res: Response): Promise => { await pageService.deleteOne(req.params.pageId); const pages = await pageService.readAll(); - req.app.get('io').of('/pageList').emit('PageListUpdate', pages); + req.app + .get('io') + .of('/pageList') + .emit('PageListUpdate', { + currentPageId: (req.session as any).pageId, + pages, + }); res.status(StatusCode.OK).json({ pages }); }, );