@@ -127,38 +127,10 @@ qx.Class.define("osparc.study.Conversations", {
127127        socket . on ( eventName ,  eventHandler ,  this ) ; 
128128        this . __wsHandlers . push ( {  eventName,  handler : eventHandler  } ) ; 
129129      } ) ; 
130- 
131-       [ 
132-         osparc . data . model . Conversation . CHANNELS . CONVERSATION_MESSAGE_CREATED , 
133-         osparc . data . model . Conversation . CHANNELS . CONVERSATION_MESSAGE_UPDATED , 
134-         osparc . data . model . Conversation . CHANNELS . CONVERSATION_MESSAGE_DELETED , 
135-       ] . forEach ( eventName  =>  { 
136-         const  eventHandler  =  message  =>  { 
137-           if  ( message )  { 
138-             const  conversationId  =  message [ "conversationId" ] ; 
139-             const  conversationPage  =  this . __getConversationPage ( conversationId ) ; 
140-             if  ( conversationPage )  { 
141-               switch  ( eventName )  { 
142-                 case  osparc . data . model . Conversation . CHANNELS . CONVERSATION_MESSAGE_CREATED :
143-                   conversationPage . addMessage ( message ) ; 
144-                   break ; 
145-                 case  osparc . data . model . Conversation . CHANNELS . CONVERSATION_MESSAGE_UPDATED :
146-                   conversationPage . updateMessage ( message ) ; 
147-                   break ; 
148-                 case  osparc . data . model . Conversation . CHANNELS . CONVERSATION_MESSAGE_DELETED :
149-                   conversationPage . deleteMessage ( message ) ; 
150-                   break ; 
151-               } 
152-             } 
153-           } 
154-         } ; 
155-         socket . on ( eventName ,  eventHandler ,  this ) ; 
156-         this . __wsHandlers . push ( {  eventName,  handler : eventHandler  } ) ; 
157-       } ) ; 
158130    } , 
159131
160132    __getConversationPage : function ( conversationId )  { 
161-       return  this . __conversationsPages . find ( conversation  =>  conversation . getConversationId ( )  ===  conversationId ) ; 
133+       return  this . __conversationsPages . find ( conversationPage  =>  conversationPage . getConversation ( )   &&   conversationPage . getConversation ( ) . getConversationId ( )  ===  conversationId ) ; 
162134    } , 
163135
164136    __applyStudyData : function ( studyData )  { 
@@ -171,7 +143,7 @@ qx.Class.define("osparc.study.Conversations", {
171143            conversations . forEach ( conversation  =>  this . __addConversationPage ( conversation ) ) ; 
172144            if  ( this . __openConversationId )  { 
173145              const  conversationsLayout  =  this . getChildControl ( "conversations-layout" ) ; 
174-               const  conversation  =  conversationsLayout . getSelectables ( ) . find ( c  =>  c . getConversationId ( )  ===  this . __openConversationId ) ; 
146+               const  conversation  =  conversationsLayout . getSelectables ( ) . find ( c  =>  c . getConversationId ( )  &&   c . getConversationId ( ) . getConversationId ( )   ===  this . __openConversationId ) ; 
175147              if  ( conversation )  { 
176148                conversationsLayout . setSelection ( [ conversation ] ) ; 
177149              } 
@@ -191,9 +163,9 @@ qx.Class.define("osparc.study.Conversations", {
191163      const  studyData  =  this . getStudyData ( ) ; 
192164      let  conversationPage  =  null ; 
193165      if  ( conversationData )  { 
194-         const  conversationId  =  conversationData [ "conversationId" ] ; 
195-         conversationPage  =  new  osparc . study . Conversation ( studyData ,  conversationId ) ; 
166+         conversationPage  =  new  osparc . study . Conversation ( studyData ,  conversationData ) ; 
196167        conversationPage . setLabel ( conversationData [ "name" ] ) ; 
168+         const  conversationId  =  conversationData [ "conversationId" ] ; 
197169        osparc . store . ConversationsProject . getInstance ( ) . addListener ( "conversationDeleted" ,  e  =>  { 
198170          const  data  =  e . getData ( ) ; 
199171          if  ( conversationId  ===  data [ "conversationId" ] )  { 
@@ -233,7 +205,7 @@ qx.Class.define("osparc.study.Conversations", {
233205      const  conversationsLayout  =  this . getChildControl ( "conversations-layout" ) ; 
234206      if  ( conversationsLayout . getChildren ( ) . length  ===  1 )  { 
235207        // remove the temporary conversation page 
236-         if  ( conversationsLayout . getChildren ( ) [ 0 ] . getConversationId ( )  ===  null )  { 
208+         if  ( conversationsLayout . getChildren ( ) [ 0 ] . getConversation ( )  ===  null )  { 
237209          conversationsLayout . remove ( conversationsLayout . getChildren ( ) [ 0 ] ) ; 
238210        } 
239211      } 
0 commit comments