@@ -147,32 +147,34 @@ qx.Class.define("osparc.support.Conversation", {
147147 const shareProjectLayout = this . getChildControl ( "share-project-layout" ) ;
148148 const currentStudy = osparc . store . Store . getInstance ( ) . getCurrentStudy ( ) ;
149149 let showCB = false ;
150- if ( currentStudy ) {
151- if ( conversation ) {
152- if ( conversation . getContextProjectId ( ) === currentStudy . getUuid ( ) ) {
153- showCB = true ;
154- }
155- } else {
156- showCB = true ;
157- }
150+ if ( conversation === null && currentStudy ) {
151+ // initiating conversation
152+ showCB = true ;
158153 }
159- shareProjectLayout . setVisibility ( showCB ? "visible" : "excluded" ) ;
160-
161- if ( currentStudy && conversation && conversation . getContextProjectId ( ) === currentStudy . getUuid ( ) ) {
162- let isAlreadyShared = false ;
163- const accessRights = currentStudy . getAccessRights ( ) ;
164- const supportGroupId = osparc . store . Products . getInstance ( ) . getSupportGroupId ( ) ;
165- if ( supportGroupId && supportGroupId in accessRights ) {
166- isAlreadyShared = true ;
167- } else {
168- isAlreadyShared = false ;
169- }
170- shareProjectCB . setValue ( isAlreadyShared ) ;
154+ if ( conversation && conversation . getContextProjectId ( ) ) {
155+ // it was already set
156+ showCB = true ;
171157 }
158+ shareProjectLayout . setVisibility ( showCB ? "visible" : "excluded" ) ;
172159
173- shareProjectCB . removeListener ( "changeValue" , this . __shareProjectWithSupport , this ) ;
174- if ( showCB ) {
175- shareProjectCB . addListener ( "changeValue" , this . __shareProjectWithSupport , this ) ;
160+ if ( conversation && conversation . getContextProjectId ( ) ) {
161+ const projectId = conversation . getContextProjectId ( ) ;
162+ osparc . store . Study . getInstance ( ) . getOne ( projectId )
163+ . then ( studyData => {
164+ let isAlreadyShared = false ;
165+ const accessRights = studyData [ "accessRights" ] ;
166+ const supportGroupId = osparc . store . Products . getInstance ( ) . getSupportGroupId ( ) ;
167+ if ( supportGroupId && supportGroupId in accessRights ) {
168+ isAlreadyShared = true ;
169+ } else {
170+ isAlreadyShared = false ;
171+ }
172+ shareProjectCB . setValue ( isAlreadyShared ) ;
173+ shareProjectCB . removeListener ( "changeValue" , this . __shareProjectWithSupport , this ) ;
174+ if ( showCB ) {
175+ shareProjectCB . addListener ( "changeValue" , this . __shareProjectWithSupport , this ) ;
176+ }
177+ } ) ;
176178 }
177179 } ,
178180
0 commit comments