@@ -45,11 +45,6 @@ qx.Class.define("osparc.store.Groups", {
4545 check : "osparc.data.model.Group" ,
4646 init : { }
4747 } ,
48-
49- users : {
50- check : "Object" ,
51- init : { }
52- } ,
5348 } ,
5449
5550 events : {
@@ -126,7 +121,8 @@ qx.Class.define("osparc.store.Groups", {
126121 this . __fetchGroups ( )
127122 . then ( orgs => {
128123 // reset Users
129- this . resetUsers ( ) ;
124+ const usersStore = osparc . store . Users . getInstance ( ) ;
125+ usersStore . resetUsers ( ) ;
130126 const promises = Object . keys ( orgs ) . map ( orgId => this . __fetchGroupMembers ( orgId ) ) ;
131127 Promise . all ( promises )
132128 . then ( ( ) => resolve ( ) )
@@ -151,7 +147,8 @@ qx.Class.define("osparc.store.Groups", {
151147 allGroupsAndUsers [ organization . getGroupId ( ) ] = organization ;
152148 } ) ;
153149
154- Object . values ( this . getUsers ( ) ) . forEach ( user => {
150+ const users = osparc . store . Users . getInstance ( ) . getUsers ( ) ;
151+ users . forEach ( user => {
155152 allGroupsAndUsers [ user . getGroupId ( ) ] = user ;
156153 } ) ;
157154
@@ -173,7 +170,9 @@ qx.Class.define("osparc.store.Groups", {
173170 groupMe [ "collabType" ] = 2 ;
174171 groups . push ( groupMe ) ;
175172
176- Object . values ( this . getUsers ( ) ) . forEach ( user => {
173+ const usersStore = osparc . store . Users . getInstance ( ) ;
174+ const users = usersStore . getUsers ( ) ;
175+ users . forEach ( user => {
177176 user [ "collabType" ] = 2 ;
178177 groups . push ( user ) ;
179178 } ) ;
@@ -201,6 +200,12 @@ qx.Class.define("osparc.store.Groups", {
201200 const potentialCollaborators = { } ;
202201 const orgs = this . getOrganizations ( ) ;
203202 const productEveryone = this . getEveryoneProductGroup ( ) ;
203+
204+ if ( includeProductEveryone && productEveryone ) {
205+ productEveryone [ "collabType" ] = 0 ;
206+ potentialCollaborators [ productEveryone . getGroupId ( ) ] = productEveryone ;
207+ }
208+
204209 Object . values ( orgs ) . forEach ( org => {
205210 if ( org . getAccessRights ( ) [ "read" ] ) {
206211 // maybe because of migration script, some users have access to the product everyone group
@@ -212,20 +217,20 @@ qx.Class.define("osparc.store.Groups", {
212217 potentialCollaborators [ org . getGroupId ( ) ] = org ;
213218 }
214219 } ) ;
215- const users = this . getUsers ( ) ;
216- for ( const gid of Object . keys ( users ) ) {
217- users [ gid ] [ "collabType" ] = 2 ;
218- potentialCollaborators [ gid ] = users [ gid ] ;
219- }
220+
220221 if ( includeMe ) {
221222 const myGroup = this . getGroupMe ( ) ;
222223 myGroup [ "collabType" ] = 2 ;
223224 potentialCollaborators [ myGroup . getGroupId ( ) ] = myGroup ;
224225 }
225- if ( includeProductEveryone && productEveryone ) {
226- productEveryone [ "collabType" ] = 0 ;
227- potentialCollaborators [ productEveryone . getGroupId ( ) ] = productEveryone ;
228- }
226+
227+ const usersStore = osparc . store . Users . getInstance ( ) ;
228+ const users = usersStore . getUsers ( ) ;
229+ users . forEach ( user => {
230+ user [ "collabType" ] = 2 ;
231+ potentialCollaborators [ user . getGroupId ( ) ] = user ;
232+ } ) ;
233+
229234 return potentialCollaborators ;
230235 } ,
231236
@@ -239,16 +244,18 @@ qx.Class.define("osparc.store.Groups", {
239244
240245 getUserByUserId : function ( userId ) {
241246 if ( userId ) {
242- const users = this . getUsers ( ) ;
243- return Object . values ( users ) . find ( member => member . getUserId ( ) === userId ) ;
247+ const usersStore = osparc . store . Users . getInstance ( ) ;
248+ const users = usersStore . getUsers ( ) ;
249+ return users . find ( user => user . getUserId ( ) === userId ) ;
244250 }
245251 return null ;
246252 } ,
247253
248254 getUserByGroupId : function ( groupId ) {
249255 if ( groupId ) {
250- const users = this . getUsers ( ) ;
251- return Object . values ( users ) . find ( member => member . getGroupId ( ) === groupId ) ;
256+ const usersStore = osparc . store . Users . getInstance ( ) ;
257+ const users = usersStore . getUsers ( ) ;
258+ return users . find ( user => user . getGroupId ( ) === groupId ) ;
252259 }
253260 return null ;
254261 } ,
@@ -426,7 +433,6 @@ qx.Class.define("osparc.store.Groups", {
426433 organization . addGroupMember ( userMember ) ;
427434 }
428435 }
429- this . getUsers ( ) [ userMember . getGroupId ( ) ] = userMember ;
430436 osparc . store . Users . getInstance ( ) . addUser ( orgMember ) ;
431437 } ,
432438
0 commit comments