@@ -27,7 +27,7 @@ qx.Class.define("osparc.study.Conversations", {
2727
2828 this . _setLayout ( new qx . ui . layout . VBox ( ) ) ;
2929
30- this . __conversations = [ ] ;
30+ this . __conversationsPages = [ ] ;
3131 this . __openConversationId = openConversationId ;
3232
3333 this . set ( {
@@ -126,17 +126,17 @@ qx.Class.define("osparc.study.Conversations", {
126126 const eventHandler = message => {
127127 if ( message ) {
128128 const conversationId = message [ "conversationId" ] ;
129- const conversation = this . __getConversation ( conversationId ) ;
130- if ( conversation ) {
129+ const conversationPage = this . __getConversationPage ( conversationId ) ;
130+ if ( conversationPage ) {
131131 switch ( eventName ) {
132132 case "conversation:message:created" :
133- conversation . addMessage ( message ) ;
133+ conversationPage . addMessage ( message ) ;
134134 break ;
135135 case "conversation:message:updated" :
136- conversation . updateMessage ( message ) ;
136+ conversationPage . updateMessage ( message ) ;
137137 break ;
138138 case "conversation:message:deleted" :
139- conversation . deleteMessage ( message ) ;
139+ conversationPage . deleteMessage ( message ) ;
140140 break ;
141141 }
142142 }
@@ -147,8 +147,8 @@ qx.Class.define("osparc.study.Conversations", {
147147 } ) ;
148148 } ,
149149
150- __getConversation : function ( conversationId ) {
151- return this . __conversations . find ( conversation => conversation . getConversationId ( ) === conversationId ) ;
150+ __getConversationPage : function ( conversationId ) {
151+ return this . __conversationsPages . find ( conversation => conversation . getConversationId ( ) === conversationId ) ;
152152 } ,
153153
154154 __applyStudyData : function ( studyData ) {
@@ -206,15 +206,15 @@ qx.Class.define("osparc.study.Conversations", {
206206 __addConversationPage : function ( conversationData ) {
207207 // ignore it if it was already there
208208 const conversationId = conversationData [ "conversationId" ] ;
209- const conversation = this . __getConversation ( conversationId ) ;
210- if ( conversation ) {
209+ const conversationPageFound = this . __getConversationPage ( conversationId ) ;
210+ if ( conversationPageFound ) {
211211 return null ;
212212 }
213213
214214 const conversationPage = this . __createConversationPage ( conversationData ) ;
215215 this . __addToPages ( conversationPage ) ;
216216
217- this . __conversations . push ( conversationPage ) ;
217+ this . __conversationsPages . push ( conversationPage ) ;
218218
219219 return conversationPage ;
220220 } ,
@@ -234,10 +234,10 @@ qx.Class.define("osparc.study.Conversations", {
234234 enabled : osparc . data . model . Study . canIWrite ( studyData [ "accessRights" ] ) ,
235235 } ) ;
236236 newConversationButton . addListener ( "execute" , ( ) => {
237- osparc . store . Conversations . getInstance ( ) . addConversation ( studyData [ "uuid" ] , "new " + ( this . __conversations . length + 1 ) )
237+ osparc . store . Conversations . getInstance ( ) . addConversation ( studyData [ "uuid" ] , "new " + ( this . __conversationsPages . length + 1 ) )
238238 . then ( conversationDt => {
239239 this . __addConversationPage ( conversationDt ) ;
240- const newConversationPage = this . __getConversation ( conversationDt [ "conversationId" ] ) ;
240+ const newConversationPage = this . __getConversationPage ( conversationDt [ "conversationId" ] ) ;
241241 if ( newConversationPage ) {
242242 conversationsLayout . setSelection ( [ newConversationPage ] ) ;
243243 }
@@ -251,11 +251,13 @@ qx.Class.define("osparc.study.Conversations", {
251251 } ,
252252
253253 __removeConversationPage : function ( conversationId , changeSelection = false ) {
254- const conversation = this . __getConversation ( conversationId ) ;
255- if ( conversation ) {
254+ const conversationPage = this . __getConversationPage ( conversationId ) ;
255+ if ( conversationPage ) {
256256 const conversationsLayout = this . getChildControl ( "conversations-layout" ) ;
257- conversationsLayout . remove ( conversation ) ;
258- this . __conversations = this . __conversations . filter ( c => c !== conversation ) ;
257+ if ( conversationsLayout . indexOf ( conversationPage ) > - 1 ) {
258+ conversationsLayout . remove ( conversationPage ) ;
259+ }
260+ this . __conversationsPages = this . __conversationsPages . filter ( c => c !== conversationPage ) ;
259261 const conversationPages = conversationsLayout . getSelectables ( ) ;
260262 if ( conversationPages . length ) {
261263 if ( changeSelection ) {
@@ -272,9 +274,9 @@ qx.Class.define("osparc.study.Conversations", {
272274 // it can only be renamed, not updated
273275 __updateConversationName : function ( conversationData ) {
274276 const conversationId = conversationData [ "conversationId" ] ;
275- const conversation = this . __getConversation ( conversationId ) ;
276- if ( conversation ) {
277- conversation . renameConversation ( conversationData [ "name" ] ) ;
277+ const conversationPage = this . __getConversationPage ( conversationId ) ;
278+ if ( conversationPage ) {
279+ conversationPage . renameConversation ( conversationData [ "name" ] ) ;
278280 }
279281 } ,
280282
0 commit comments