@@ -1238,7 +1238,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
12381238 this . __setSelectedAnnotations ( [ annotation ] ) ;
12391239 switch ( annotation . getType ( ) ) {
12401240 case osparc . workbench . Annotation . TYPES . CONVERSATION : {
1241- this . __popUpConversation ( annotation . getAttributes ( ) [ "conversationId" ] ) ;
1241+ this . __popUpConversation ( annotation . getAttributes ( ) [ "conversationId" ] , annotation . getId ( ) ) ;
12421242 break ;
12431243 }
12441244 default : {
@@ -1992,8 +1992,8 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
19921992 . then ( conversationData => {
19931993 serializeData . attributes . conversationId = conversationData [ "conversationId" ] ;
19941994 serializeData . attributes . text = conversationData [ "name" ] ;
1995- this . __addAnnotation ( serializeData ) ;
1996- this . __popUpConversation ( conversationData [ "conversationId" ] ) ;
1995+ const annotation = this . __addAnnotation ( serializeData ) ;
1996+ this . __popUpConversation ( conversationData [ "conversationId" ] , annotation . getId ( ) ) ;
19971997 } ) ;
19981998 break ;
19991999 }
@@ -2008,6 +2008,8 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
20082008 this . getStudy ( ) . getUi ( ) . addAnnotation ( annotation ) ;
20092009
20102010 this . __renderAnnotation ( annotation ) ;
2011+
2012+ return annotation ;
20112013 } ,
20122014
20132015 __renderAnnotation : function ( annotation ) {
@@ -2034,8 +2036,26 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
20342036 }
20352037 } ,
20362038
2037- __popUpConversation : function ( conversationId ) {
2039+ __popUpConversation : function ( conversationId , annotationId ) {
20382040 osparc . study . Conversations . popUpInWindow ( this . getStudy ( ) . serialize ( ) , conversationId ) ;
2041+
2042+ // Check if conversation still exists, if not, ask to remove annotation
2043+ osparc . store . Conversations . getInstance ( ) . getConversation ( this . getStudy ( ) . getUuid ( ) , conversationId )
2044+ . catch ( err => {
2045+ if ( "status" in err && err . status === 404 ) {
2046+ const win = new osparc . ui . window . Confirmation ( this . tr ( "Do you want to remove the annotation?" ) ) . set ( {
2047+ caption : this . tr ( "Conversation not found" ) ,
2048+ confirmText : this . tr ( "Delete" ) ,
2049+ confirmAction : "delete" ,
2050+ } ) ;
2051+ win . open ( ) ;
2052+ win . addListener ( "close" , ( ) => {
2053+ if ( win . getConfirmed ( ) ) {
2054+ this . __removeAnnotation ( annotationId ) ;
2055+ }
2056+ } ) ;
2057+ }
2058+ } ) ;
20392059 } ,
20402060
20412061 __dropFile : async function ( e ) {
0 commit comments