@@ -139,46 +139,44 @@ qx.Class.define("osparc.support.Conversation", {
139139 } ,
140140
141141 __evaluateShareProject : function ( ) {
142- const conversation = this . getConversation ( ) ;
143-
144142 const shareProjectLayout = this . getChildControl ( "share-project-layout" ) ;
145- const currentStudy = osparc . store . Store . getInstance ( ) . getCurrentStudy ( ) ;
146143 let showLayout = false ;
147144 let enabledLayout = false ;
148- if ( conversation && currentStudy ) {
149- // it was already set
150- showLayout = conversation . getContextProjectId ( ) ;
151- enabledLayout = conversation . amIOwner ( ) && osparc . data . model . Study . canIWrite ( currentStudy . getAccessRights ( ) ) ;
145+ const conversation = this . getConversation ( ) ;
146+ if ( conversation ) {
147+ showLayout = Boolean ( conversation . getContextProjectId ( ) ) ;
148+ enabledLayout = conversation . amIOwner ( ) ;
152149 }
153150 shareProjectLayout . set ( {
154151 visibility : showLayout ? "visible" : "excluded" ,
155152 enabled : enabledLayout ,
156153 } ) ;
157154
158155 if ( showLayout ) {
159- const projectId = conversation . getContextProjectId ( ) ;
160- if ( currentStudy && projectId === currentStudy . getUuid ( ) ) {
161- this . __populateShareProjectCB ( ) ;
162- currentStudy . addListener ( "changeAccessRights" , ( ) => this . __populateShareProjectCB ( ) , this ) ;
163- }
156+ this . __populateShareProjectCB ( ) ;
157+ const currentStudy = osparc . store . Store . getInstance ( ) . getCurrentStudy ( ) ;
158+ currentStudy . addListener ( "changeAccessRights" , ( ) => this . __populateShareProjectCB ( ) , this ) ;
164159 }
165160 } ,
166161
167162 __populateShareProjectCB : function ( ) {
168- const projectId = conversation . getContextProjectId ( ) ;
169- osparc . store . Study . getInstance ( ) . getOne ( projectId )
170- . then ( studyData => {
171- let isAlreadyShared = false ;
172- const accessRights = studyData [ "accessRights" ] ;
173- const supportGroupId = osparc . store . Groups . getInstance ( ) . getSupportGroup ( ) . getGroupId ( ) ;
174- if ( supportGroupId && supportGroupId in accessRights ) {
175- isAlreadyShared = true ;
176- } else {
177- isAlreadyShared = false ;
178- }
179- const shareProjectCB = this . getChildControl ( "share-project-checkbox" ) ;
180- shareProjectCB . setValue ( isAlreadyShared ) ;
181- } ) ;
163+ const conversation = this . getConversation ( ) ;
164+ if ( conversation && conversation . getContextProjectId ( ) ) {
165+ const projectId = conversation . getContextProjectId ( ) ;
166+ osparc . store . Study . getInstance ( ) . getOne ( projectId )
167+ . then ( studyData => {
168+ let isAlreadyShared = false ;
169+ const accessRights = studyData [ "accessRights" ] ;
170+ const supportGroupId = osparc . store . Groups . getInstance ( ) . getSupportGroup ( ) . getGroupId ( ) ;
171+ if ( supportGroupId && supportGroupId in accessRights ) {
172+ isAlreadyShared = true ;
173+ } else {
174+ isAlreadyShared = false ;
175+ }
176+ const shareProjectCB = this . getChildControl ( "share-project-checkbox" ) ;
177+ shareProjectCB . setValue ( isAlreadyShared ) ;
178+ } ) ;
179+ }
182180 } ,
183181
184182 __shareProjectWithSupport : function ( share ) {
0 commit comments