@@ -148,7 +148,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
148148 return false ;
149149 } ,
150150
151- populateShareIcon : async function ( shareIcon , accessRights ) {
151+ populateShareIcon : function ( shareIcon , accessRights ) {
152152 const gids = Object . keys ( accessRights ) . map ( key => parseInt ( key ) ) ;
153153
154154 const groupsStore = osparc . store . Groups . getInstance ( ) ;
@@ -169,6 +169,16 @@ qx.Class.define("osparc.dashboard.CardBase", {
169169 }
170170
171171 // Tooltip
172+ const canIWrite = osparc . data . model . Study . canIWrite ( accessRights ) ;
173+ if ( gids . length === 0 ) {
174+ if ( canIWrite ) {
175+ shareIcon . set ( {
176+ toolTipText : qx . locale . Manager . tr ( "Share" )
177+ } ) ;
178+ }
179+ return ;
180+ }
181+
172182 const sharedGrps = [ ] ;
173183 const groups = [ ] ;
174184 groups . push ( groupEveryone ) ;
@@ -181,43 +191,43 @@ qx.Class.define("osparc.dashboard.CardBase", {
181191 gids . splice ( idx , 1 ) ;
182192 }
183193 } ) ;
184- // once the groups were removed, the remaining group ids are users' primary groups ids
185- const usersStore = osparc . store . Users . getInstance ( ) ;
186- const myGroupId = groupsStore . getMyGroupId ( ) ;
187- for ( let i = 0 ; i < gids . length ; i ++ ) {
188- const gid = gids [ i ] ;
189- if ( myGroupId !== gid ) {
190- const user = await usersStore . getUser ( gid ) ;
191- if ( user ) {
192- sharedGrps . push ( user ) ;
194+
195+ const hint = new osparc . ui . hint . Hint ( shareIcon ) ;
196+ shareIcon . addListener ( "mouseover" , async ( ) => {
197+ hint . show ( ) ;
198+
199+ // lazy load tooltip, this can be an expensive call
200+
201+ // once the groups were removed, the remaining group ids are users' primary groups ids
202+ const usersStore = osparc . store . Users . getInstance ( ) ;
203+ const myGroupId = groupsStore . getMyGroupId ( ) ;
204+ for ( let i = 0 ; i < gids . length ; i ++ ) {
205+ const gid = gids [ i ] ;
206+ if ( myGroupId !== gid ) {
207+ const user = await usersStore . getUser ( gid ) ;
208+ if ( user ) {
209+ sharedGrps . push ( user ) ;
210+ }
193211 }
194212 }
195- }
196213
197- const canIWrite = osparc . data . model . Study . canIWrite ( accessRights ) ;
198- if ( sharedGrps . length === 0 ) {
199- if ( canIWrite ) {
200- shareIcon . set ( {
201- toolTipText : qx . locale . Manager . tr ( "Share" )
202- } ) ;
203- }
204- return ;
205- }
206- const sharedGrpLabels = [ ] ;
207- const maxItems = 6 ;
208- for ( let i = 0 ; i < sharedGrps . length ; i ++ ) {
209- if ( i > maxItems ) {
210- sharedGrpLabels . push ( "..." ) ;
211- break ;
212- }
213- const sharedGrpLabel = sharedGrps [ i ] . getLabel ( ) ;
214- if ( ! sharedGrpLabels . includes ( sharedGrpLabel ) ) {
215- sharedGrpLabels . push ( sharedGrpLabel ) ;
214+ if ( hint . getText ( ) === "" ) {
215+ const sharedGrpLabels = [ ] ;
216+ const maxItems = 6 ;
217+ for ( let i = 0 ; i < sharedGrps . length ; i ++ ) {
218+ if ( i > maxItems ) {
219+ sharedGrpLabels . push ( "..." ) ;
220+ break ;
221+ }
222+ const sharedGrpLabel = sharedGrps [ i ] . getLabel ( ) ;
223+ if ( ! sharedGrpLabels . includes ( sharedGrpLabel ) ) {
224+ sharedGrpLabels . push ( sharedGrpLabel ) ;
225+ }
226+ }
227+ const hintText = sharedGrpLabels . join ( "<br>" ) ;
228+ hint . setText ( hintText )
216229 }
217- }
218- const hintText = sharedGrpLabels . join ( "<br>" ) ;
219- const hint = new osparc . ui . hint . Hint ( shareIcon , hintText ) ;
220- shareIcon . addListener ( "mouseover" , ( ) => hint . show ( ) , this ) ;
230+ } , this ) ;
221231 shareIcon . addListener ( "mouseout" , ( ) => hint . exclude ( ) , this ) ;
222232 } ,
223233 } ,
0 commit comments