|
|
|
@@ -39,7 +39,6 @@ export class UserDetailComponent implements OnInit, AfterViewInit { |
|
|
|
|
|
|
|
protected userSub: Subscription; |
|
|
|
protected isCurrentUser: boolean; |
|
|
|
protected userId!: string; |
|
|
|
|
|
|
|
constructor( |
|
|
|
private accountService: AccountService, |
|
|
|
@@ -48,34 +47,44 @@ export class UserDetailComponent implements OnInit, AfterViewInit { |
|
|
|
private route: ActivatedRoute, |
|
|
|
) { |
|
|
|
this.userSub = new Subscription(); |
|
|
|
|
|
|
|
this.isCurrentUser = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
this.route.params.subscribe(params => { |
|
|
|
this.userId = params['id']; |
|
|
|
}); |
|
|
|
console.log(this.userId); |
|
|
|
if (this.user === undefined) { |
|
|
|
this.route.params.subscribe(params => { |
|
|
|
this.getUserData(params['id']); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
this.setIsCurrentUser(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ngAfterViewInit(): void { |
|
|
|
if (this.accountService.userValue?.userResource) { |
|
|
|
let user = this.accountService.userValue?.userResource; |
|
|
|
this.isCurrentUser = this.userId == user?.id; |
|
|
|
} |
|
|
|
this.getData(); |
|
|
|
// if (this.accountService.userValue?.userResource) { |
|
|
|
// let user = this.accountService.userValue?.userResource; |
|
|
|
// if (this.user.id === user.id) { |
|
|
|
// this.isCurrentUser = true; |
|
|
|
// } |
|
|
|
// this.isCurrentUser = this.userId == user?.id; |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
getData() { |
|
|
|
|
|
|
|
getUserData(userId: string) { |
|
|
|
this.userSub = this.userService.usersIdGet( |
|
|
|
this.userId |
|
|
|
userId |
|
|
|
).subscribe( |
|
|
|
data => { |
|
|
|
this.user = data; |
|
|
|
this.setIsCurrentUser(); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
setIsCurrentUser() { |
|
|
|
if (this.accountService.userValue?.userResource) { |
|
|
|
let user = this.accountService.userValue?.userResource; |
|
|
|
this.isCurrentUser = this.user.id == user?.id; |
|
|
|
} |
|
|
|
} |
|
|
|
} |