@@ -7,7 +7,13 @@ export const create = transactionHandler(
7
7
async ( req : Request , res : Response ) : Promise < void > => {
8
8
const page = await pageService . create ( req . body . page ) ;
9
9
const pages = await pageService . readAll ( ) ;
10
- req . app . get ( 'io' ) . of ( '/pageList' ) . emit ( 'PageListUpdate' , pages ) ;
10
+ req . app
11
+ . get ( 'io' )
12
+ . of ( '/pageList' )
13
+ . emit ( 'PageListUpdate' , {
14
+ currentPageId : ( req . session as any ) . pageId ,
15
+ pages,
16
+ } ) ;
11
17
res . status ( StatusCode . CREATED ) . json ( { page, pages } ) ;
12
18
} ,
13
19
) ;
@@ -25,15 +31,27 @@ export const readAll = async (req: Request, res: Response): Promise<void> => {
25
31
export const update = async ( req : Request , res : Response ) : Promise < void > => {
26
32
const page = await pageService . update ( req . params . pageId , req . body . page ) ;
27
33
const pages = await pageService . readAll ( ) ;
28
- req . app . get ( 'io' ) . of ( '/pageList' ) . emit ( 'PageListUpdate' , pages ) ;
34
+ req . app
35
+ . get ( 'io' )
36
+ . of ( '/pageList' )
37
+ . emit ( 'PageListUpdate' , {
38
+ currentPageId : ( req . session as any ) . pageId ,
39
+ pages,
40
+ } ) ;
29
41
res . status ( StatusCode . OK ) . json ( { page } ) ;
30
42
} ;
31
43
32
44
export const deleteOne = transactionHandler (
33
45
async ( req : Request , res : Response ) : Promise < void > => {
34
46
await pageService . deleteOne ( req . params . pageId ) ;
35
47
const pages = await pageService . readAll ( ) ;
36
- req . app . get ( 'io' ) . of ( '/pageList' ) . emit ( 'PageListUpdate' , pages ) ;
48
+ req . app
49
+ . get ( 'io' )
50
+ . of ( '/pageList' )
51
+ . emit ( 'PageListUpdate' , {
52
+ currentPageId : ( req . session as any ) . pageId ,
53
+ pages,
54
+ } ) ;
37
55
res . status ( StatusCode . OK ) . json ( { pages } ) ;
38
56
} ,
39
57
) ;
0 commit comments