Skip to content

Commit

Permalink
🐛 [Frontend] Bugfix: handle better groups/${gid}/users error (#7048)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Jan 16, 2025
1 parent 2460775 commit 7cba3a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
const usersStore = osparc.store.Users.getInstance();
selectedMembers.forEach(selectedMemberGId => promises.push(usersStore.getUser(selectedMemberGId)));
Promise.all(promises)
.then(users => {
users.forEach(user => this.__addMember(user.getUsername()));
})
.catch(err => {
console.error(err);
.then(values => {
values.forEach(user => {
if (user) {
this.__addMember(user.getUsername());
}
});
})
.catch(console.error)
.finally(collaboratorsManager.close());
} else {
collaboratorsManager.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ qx.Class.define("osparc.store.Users", {
},

members: {
fetchUser: function(groupId) {
__fetchUser: function(groupId) {
const params = {
url: {
gid: groupId
Expand All @@ -41,14 +41,22 @@ qx.Class.define("osparc.store.Users", {
});
},

getUser: function(groupId, fetchIfNotFound = true) {
getUser: async function(groupId, fetchIfNotFound = true) {
const userFound = this.getUsers().find(user => user.getGroupId() === groupId);
if (userFound) {
return new Promise(resolve => resolve(userFound));
} else if (fetchIfNotFound) {
return this.fetchUser(groupId);
return userFound;
}
return new Promise(reject => reject());
if (fetchIfNotFound) {
try {
const user = await this.__fetchUser(groupId);
if (user) {
return user;
}
} catch (error) {
console.error(error);
}
}
return null;
},

addUser: function(userData) {
Expand Down

0 comments on commit 7cba3a6

Please sign in to comment.