@@ -140,16 +140,21 @@ qx.Class.define("osparc.info.CommentAdd", {
140140 const data = e . getData ( ) ;
141141 const userGids = data [ "selectedGids" ] ;
142142 if ( userGids && userGids . length ) {
143- // OM: suggest sharing the study first if the user is not a collaborator
144143 const userGid = parseInt ( userGids [ 0 ] ) ;
145- if ( this . __conversationId ) {
146- this . __postNotify ( userGid ) ;
144+ // Note: this check only works if the project is directly shared with the user.
145+ // If it's shared through a group, it might be a bit confusing
146+ if ( userGid in this . __studyData [ "accessRights" ] ) {
147+ this . __addNotify ( userGid ) ;
147148 } else {
148- // create new conversation first
149- osparc . study . Conversations . addConversation ( this . __studyData [ "uuid" ] )
150- . then ( data => {
151- this . __conversationId = data [ "conversationId" ] ;
152- this . __postNotify ( userGid ) ;
149+ const newCollaborators = [ {
150+ userGid : osparc . data . Roles . STUDY [ "write" ] . accessRights
151+ } ] ;
152+ osparc . store . Study . addCollaborators ( this . __studyData , newCollaborators )
153+ . then ( ( ) => {
154+ this . __addNotify ( userGid ) ;
155+ } )
156+ . catch ( err => {
157+ console . error ( "Failed to add collaborator:" , err ) ;
153158 } ) ;
154159 }
155160 }
@@ -169,6 +174,19 @@ qx.Class.define("osparc.info.CommentAdd", {
169174 }
170175 } ,
171176
177+ __addNotify : function ( userGid ) {
178+ if ( this . __conversationId ) {
179+ this . __postNotify ( userGid ) ;
180+ } else {
181+ // create new conversation first
182+ osparc . study . Conversations . addConversation ( this . __studyData [ "uuid" ] )
183+ . then ( data => {
184+ this . __conversationId = data [ "conversationId" ] ;
185+ this . __postNotify ( userGid ) ;
186+ } ) ;
187+ }
188+ } ,
189+
172190 __postMessage : function ( ) {
173191 const commentField = this . getChildControl ( "comment-field" ) ;
174192 const comment = commentField . getChildControl ( "text-area" ) . getValue ( ) ;
0 commit comments