diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-03-14 08:58:25 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-03-14 08:58:25 +0200 |
| commit | 95bcb91f281049fef320c788b71b0731b4910108 (patch) | |
| tree | c0340e8cc7a233f0094f19453ef8879ced386df8 /src/app/components/profile/profile.component.ts | |
| parent | 0d58551a6b54457fc24d926f46a6efd73e332901 (diff) | |
| download | DevHive-Angular-95bcb91f281049fef320c788b71b0731b4910108.tar DevHive-Angular-95bcb91f281049fef320c788b71b0731b4910108.tar.gz DevHive-Angular-95bcb91f281049fef320c788b71b0731b4910108.zip | |
Moved a nested http request in profile component to it's own method
Diffstat (limited to 'src/app/components/profile/profile.component.ts')
| -rw-r--r-- | src/app/components/profile/profile.component.ts | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts index 429b9b8..73e1e96 100644 --- a/src/app/components/profile/profile.component.ts +++ b/src/app/components/profile/profile.component.ts @@ -169,20 +169,24 @@ export class ProfileComponent implements OnInit { loggedInUser.friends.push(newFriend); } - this._userService.putBareUserFromSessionStorageRequest(loggedInUser, this.updateFrienship.get('password')?.value).subscribe({ - next: () => { - this.reloadPage(); - }, - error: () => { - this._router.navigate(['/']); - } - }); + this.updateUserWithNewFriends(loggedInUser); } }); } this.updatingFriendship = !this.updatingFriendship; } + private updateUserWithNewFriends(loggedInUser: User): void { + this._userService.putBareUserFromSessionStorageRequest(loggedInUser, this.updateFrienship.get('password')?.value).subscribe({ + next: () => { + this.reloadPage(); + }, + error: () => { + this._router.navigate(['/']); + } + }); + } + onScroll(event: any): void { // Detects when the element has reached the bottom, thx https://stackoverflow.com/a/50038429/12036073 if (event.target.offsetHeight + event.target.scrollTop >= event.target.scrollHeight && this._currentPage > 0) { |
