@@ -121,14 +121,17 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
121121
122122 const walletsEnabled = osparc . desktop . credits . Utils . areWalletsEnabled ( ) ;
123123 if ( walletsEnabled ) {
124- osparc . store . Study . getInstance ( ) . getWallet ( studyId )
125- . then ( wallet => {
126- if (
127- isStudyCreation ||
128- wallet === null ||
129- osparc . desktop . credits . Utils . getWallet ( wallet [ "walletId" ] ) === null
130- ) {
131- // pop up study options if the study was just created or if it has no wallet assigned or user has no access to it
124+ Promise . all ( [
125+ osparc . store . Study . getInstance ( ) . getWallet ( studyId ) ,
126+ osparc . store . Study . getInstance ( ) . getOne ( studyId ) ,
127+ ] ) . then ( ( [ wallet , latestStudyData ] ) => {
128+ const currentUserGroupIds = osparc . study . Utils . state . getCurrentGroupIds ( latestStudyData [ "state" ] ) ;
129+ const isRTCEnabled = osparc . settings . Utils . isRTCEnabled ( ) ;
130+ if ( isStudyCreation || wallet === null || currentUserGroupIds . length === 0 ) {
131+ // pop up StudyOptions if:
132+ // - the study was just created
133+ // - it has no wallet assigned
134+ // - the project is not being used
132135 const resourceSelector = new osparc . study . StudyOptions ( studyId ) ;
133136 if ( isStudyCreation ) {
134137 resourceSelector . getChildControl ( "open-button" ) . setLabel ( qx . locale . Manager . tr ( "New" ) ) ;
@@ -156,20 +159,24 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
156159 cancelCB ( ) ;
157160 }
158161 } ) ;
159- } else {
160- // Check if I have access to the current wallet. If I don't, I won't be able to open it
162+ } else if ( currentUserGroupIds . length && isRTCEnabled ) {
163+ // if the project is being used, I just want to join
164+ // check if I have access to the associated wallet
161165 const found = osparc . store . Store . getInstance ( ) . getWallets ( ) . find ( w => w . getWalletId ( ) === wallet [ "walletId" ] ) ;
162166 if ( found ) {
163- // switch to the wallet and inform the user
167+ // switch to that wallet
164168 if ( osparc . store . Store . getInstance ( ) . getContextWallet ( ) !== found ) {
169+ // inform the user that the context wallet has changed
165170 const text = qx . locale . Manager . tr ( "Switched to Credit Account" ) + " '" + found . getName ( ) + "'" ;
166171 osparc . FlashMessenger . logAs ( text ) ;
167172 }
168173 osparc . store . Store . getInstance ( ) . setActiveWallet ( found ) ;
169174 openStudy ( ) ;
170175 } else {
171176 // cancel and explain the user why
172- const msg = qx . locale . Manager . tr ( "You can't join the project because you don't have access to the Credit Account associated with it. Please contact the project owner." ) ;
177+ const msg = isRTCEnabled ?
178+ qx . locale . Manager . tr ( "You can't join the project because you don't have access to the Credit Account associated with it. Please contact the project owner." ) :
179+ qx . locale . Manager . tr ( "You can't join the project because it's already open by another user." ) ;
173180 osparc . FlashMessenger . logAs ( msg , "ERROR" ) ;
174181 if ( cancelCB ) {
175182 cancelCB ( ) ;
0 commit comments