Skip to content

Commit 684e3ce

Browse files
xflordHejdaJakub
authored andcommitted
fix(admin): fixed a bug that caused an incorrect member to initially load on the user accounts page
* the bug was caused by vos arrays being sorted differently in the user-accounts component and the vo select component
1 parent f5952b1 commit 684e3ce

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

apps/admin-gui/src/app/users/pages/user-detail-page/user-accounts/user-accounts.component.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from '@perun-web-apps/perun/openapi';
1010
import { ActivatedRoute } from '@angular/router';
1111
import { Urns } from '@perun-web-apps/perun/urns';
12+
import { compareFnName } from '@perun-web-apps/perun/utils';
1213

1314
@Component({
1415
selector: 'app-perun-web-apps-user-accounts',
@@ -35,44 +36,44 @@ export class UserAccountsComponent implements OnInit {
3536
this.initLoading = true;
3637
this.route.parent.params.subscribe((params) => {
3738
this.userId = Number(params['userId']);
38-
this.usersService.getVosWhereUserIsMember(this.userId).subscribe(
39-
(vos) => {
39+
this.usersService.getVosWhereUserIsMember(this.userId).subscribe({
40+
next: (vos) => {
4041
this.vos = vos;
4142
if (this.vos.length) {
42-
this.loadMember(this.vos[0]);
43+
this.loadMember(this.vos.sort(compareFnName)[0]);
4344
}
4445
this.initLoading = false;
4546
},
46-
() => (this.initLoading = false)
47-
);
47+
error: () => (this.initLoading = false),
48+
});
4849
});
4950
}
5051

5152
loadMember(vo: Vo): void {
5253
this.loading = true;
5354
this.selectedVo = vo;
54-
this.membersService.getMemberByUser(this.selectedVo.id, this.userId).subscribe(
55-
(member) => {
56-
this.membersService.getRichMemberWithAttributes(member.id).subscribe(
57-
(m) => {
55+
this.membersService.getMemberByUser(this.selectedVo.id, this.userId).subscribe({
56+
next: (member) => {
57+
this.membersService.getRichMemberWithAttributes(member.id).subscribe({
58+
next: (m) => {
5859
this.member = m;
5960
this.groupService
6061
.getMemberRichGroupsWithAttributesByNames(this.member.id, [
6162
Urns.MEMBER_DEF_GROUP_EXPIRATION,
6263
Urns.MEMBER_GROUP_STATUS,
6364
])
64-
.subscribe(
65-
(groups) => {
65+
.subscribe({
66+
next: (groups) => {
6667
this.groups = groups;
6768
this.loading = false;
6869
},
69-
() => (this.loading = false)
70-
);
70+
error: () => (this.loading = false),
71+
});
7172
},
72-
() => (this.loading = false)
73-
);
73+
error: () => (this.loading = false),
74+
});
7475
},
75-
() => (this.loading = false)
76-
);
76+
error: () => (this.loading = false),
77+
});
7778
}
7879
}

0 commit comments

Comments
 (0)