@@ -29,14 +29,6 @@ qx.Class.define("osparc.study.Conversation", {
2929 this . __studyData = studyData ;
3030 this . __messages = [ ] ;
3131
32- if ( conversationData ) {
33- const conversation = new osparc . data . model . Conversation ( conversationData , this . __studyData ) ;
34- this . setConversation ( conversation ) ;
35- this . setLabel ( conversationData [ "name" ] ) ;
36- } else {
37- this . setLabel ( this . tr ( "new" ) ) ;
38- }
39-
4032 this . _setLayout ( new qx . ui . layout . VBox ( 5 ) ) ;
4133
4234 this . set ( {
@@ -51,7 +43,13 @@ qx.Class.define("osparc.study.Conversation", {
5143
5244 this . __buildLayout ( ) ;
5345
54- this . __reloadMessages ( ) ;
46+ if ( conversationData ) {
47+ const conversation = new osparc . data . model . Conversation ( conversationData , this . __studyData ) ;
48+ this . setConversation ( conversation ) ;
49+ this . setLabel ( conversationData [ "name" ] ) ;
50+ } else {
51+ this . setLabel ( this . tr ( "new" ) ) ;
52+ }
5553 } ,
5654
5755 properties : {
@@ -74,6 +72,8 @@ qx.Class.define("osparc.study.Conversation", {
7472 __loadMoreMessages : null ,
7573
7674 __applyConversation : function ( conversation ) {
75+ this . __reloadMessages ( true ) ;
76+
7777 conversation . addListener ( "messageAdded" , e => {
7878 const message = e . getData ( ) ;
7979 this . addMessage ( message ) ;
@@ -196,10 +196,12 @@ qx.Class.define("osparc.study.Conversation", {
196196
197197 const addMessage = new osparc . conversation . AddMessage ( ) . set ( {
198198 studyData : this . __studyData ,
199- conversationId : this . getConversationId ( ) ,
200199 enabled : osparc . data . model . Study . canIWrite ( this . __studyData [ "accessRights" ] ) ,
201200 paddingLeft : 10 ,
202201 } ) ;
202+ this . bind ( "conversation" , addMessage , "conversationId" , {
203+ converter : conversation => conversation ? conversation . getConversationId ( ) : null
204+ } ) ;
203205 addMessage . addListener ( "addMessage" , e => {
204206 const content = e . getData ( ) ;
205207 const conversation = this . getConversation ( ) ;
0 commit comments