@@ -155,41 +155,44 @@ export class AiService {
155
155
156
156
rl . on ( "close" , async ( ) => {
157
157
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
+ }
193
196
} ) ;
194
197
195
198
// μλ¬ μ²λ¦¬λ μΆκ°ν μ μμ΅λλ€.
@@ -600,7 +603,7 @@ export class AiService {
600
603
pageCreator : PageCreator ,
601
604
socketId : string ,
602
605
) {
603
- if ( ! pageCreator . currentPage ) return ;
606
+ if ( ! pageCreator . currentPage ) return false ;
604
607
605
608
const pageUpdateOperation : RemotePageUpdateOperation = {
606
609
type : "pageUpdate" ,
@@ -615,9 +618,7 @@ export class AiService {
615
618
const currentPage = currentWorkspace . pageList . find (
616
619
( page ) => page . id === pageCreator . currentPage . id ,
617
620
) ;
618
- if ( ! currentPage ) {
619
- throw new Error ( `Page with id ${ pageCreator . currentPage . id } not found` ) ;
620
- }
621
+ if ( ! currentPage ) return false ;
621
622
622
623
// νμ΄μ§ λ©νλ°μ΄ν° μ
λ°μ΄νΈ
623
624
if ( pageCreator . pageTitle ) {
@@ -631,6 +632,7 @@ export class AiService {
631
632
this . workspaceService . updateWorkspace ( currentWorkspace ) ;
632
633
633
634
this . emitOperation ( workspaceId , socketId , pageUpdateOperation ) ;
635
+ return true ;
634
636
}
635
637
636
638
private determineAnimation ( type : ElementType ) : "rainbow" | "highlight" | "none" {
0 commit comments