@@ -155,41 +155,44 @@ export class AiService {
155155
156156 rl . on ( "close" , async ( ) => {
157157 await this . processToken ( "\n" , workspaceId , clientId , pageCreator , socketId ) ;
158- if ( pageCreator . pageTitle )
159- await this . updateCurrentPage ( workspaceId , clientId , pageCreator , socketId ) ;
160-
161- const currentPage = await this . workspaceService . updatePage (
162- workspaceId ,
163- pageCreator . currentPage . id ,
164- ) ;
165- const pageCreateOperation = {
166- type : "pageCreate" ,
167- workspaceId,
168- clientId,
169- page : currentPage . serialize ( ) ,
170- } as RemotePageCreateOperation ;
171-
172- this . workspaceService
173- . getServer ( )
174- . to ( workspaceId )
175- . except ( socketId )
176- . emit ( "create/page" , pageCreateOperation ) ;
177-
178- const pageUpdateOperation : RemotePageUpdateOperation = {
179- type : "pageUpdate" ,
180- workspaceId,
181- pageId : pageCreator . currentPage . id ,
182- title : pageCreator . pageTitle ,
183- icon : pageCreator . currentPage . icon ,
184- clientId,
185- } ;
186-
187- this . workspaceService
188- . getServer ( )
189- . to ( workspaceId )
190- . except ( socketId )
191- . emit ( "update/page" , pageUpdateOperation ) ;
192- console . log ( "SSE μ€νΈλ¦Όμ΄ μ’
λ£λμμ΅λλ€." ) ;
158+ if ( pageCreator . pageTitle ) {
159+ if ( await this . updateCurrentPage ( workspaceId , clientId , pageCreator , socketId ) ) {
160+ const currentPage = await this . workspaceService . updatePage (
161+ workspaceId ,
162+ pageCreator . currentPage . id ,
163+ ) ;
164+ const pageCreateOperation = {
165+ type : "pageCreate" ,
166+ workspaceId,
167+ clientId,
168+ page : currentPage . serialize ( ) ,
169+ } as RemotePageCreateOperation ;
170+
171+ this . workspaceService
172+ . getServer ( )
173+ . to ( workspaceId )
174+ . except ( socketId )
175+ . emit ( "create/page" , pageCreateOperation ) ;
176+
177+ const pageUpdateOperation : RemotePageUpdateOperation = {
178+ type : "pageUpdate" ,
179+ workspaceId,
180+ pageId : pageCreator . currentPage . id ,
181+ title : pageCreator . pageTitle ,
182+ icon : pageCreator . currentPage . icon ,
183+ clientId,
184+ } ;
185+
186+ this . workspaceService
187+ . getServer ( )
188+ . to ( workspaceId )
189+ . except ( socketId )
190+ . emit ( "update/page" , pageUpdateOperation ) ;
191+ console . log ( "SSE μ€νΈλ¦Όμ΄ μ’
λ£λμμ΅λλ€." ) ;
192+ } else {
193+ console . log ( "SSE μ€νΈλ¦Όμ΄ μ’
λ£λμμ΅λλ€. νμ΄μ§ μμ" ) ;
194+ }
195+ }
193196 } ) ;
194197
195198 // μλ¬ μ²λ¦¬λ μΆκ°ν μ μμ΅λλ€.
@@ -600,7 +603,7 @@ export class AiService {
600603 pageCreator : PageCreator ,
601604 socketId : string ,
602605 ) {
603- if ( ! pageCreator . currentPage ) return ;
606+ if ( ! pageCreator . currentPage ) return false ;
604607
605608 const pageUpdateOperation : RemotePageUpdateOperation = {
606609 type : "pageUpdate" ,
@@ -615,9 +618,7 @@ export class AiService {
615618 const currentPage = currentWorkspace . pageList . find (
616619 ( page ) => page . id === pageCreator . currentPage . id ,
617620 ) ;
618- if ( ! currentPage ) {
619- throw new Error ( `Page with id ${ pageCreator . currentPage . id } not found` ) ;
620- }
621+ if ( ! currentPage ) return false ;
621622
622623 // νμ΄μ§ λ©νλ°μ΄ν° μ
λ°μ΄νΈ
623624 if ( pageCreator . pageTitle ) {
@@ -631,6 +632,7 @@ export class AiService {
631632 this . workspaceService . updateWorkspace ( currentWorkspace ) ;
632633
633634 this . emitOperation ( workspaceId , socketId , pageUpdateOperation ) ;
635+ return true ;
634636 }
635637
636638 private determineAnimation ( type : ElementType ) : "rainbow" | "highlight" | "none" {
0 commit comments