aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-03-28 14:52:07 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-03-28 14:52:07 +0300
commit623f6dcc433149a41e93ce978ce5060ea46d7589 (patch)
tree711595a7e9af9d60752769af5048bdb25a009e45 /src/app
parentb563125ae8c57d36590c6c18f03ac9354695fc1a (diff)
downloadDevHive-Angular-623f6dcc433149a41e93ce978ce5060ea46d7589.tar
DevHive-Angular-623f6dcc433149a41e93ce978ce5060ea46d7589.tar.gz
DevHive-Angular-623f6dcc433149a41e93ce978ce5060ea46d7589.zip
Fixed some session storage request that were happening while the user wasn't logged in
Diffstat (limited to 'src/app')
-rw-r--r--src/app/components/navbar/navbar.component.ts13
-rw-r--r--src/app/components/post/post.component.ts20
2 files changed, 18 insertions, 15 deletions
diff --git a/src/app/components/navbar/navbar.component.ts b/src/app/components/navbar/navbar.component.ts
index 85f07d1..14b8f52 100644
--- a/src/app/components/navbar/navbar.component.ts
+++ b/src/app/components/navbar/navbar.component.ts
@@ -20,13 +20,14 @@ export class NavbarComponent implements OnInit {
this.loggedIn = this._tokenService.getTokenFromSessionStorage() !== '';
this.user = this._userService.getDefaultUser();
- this.user.userName = ''; // so you don't always see a flash of 'Gosho'
- this._userService.getUserFromSessionStorageRequest().subscribe({
- next: (res: object) => {
- Object.assign(this.user, res);
- },
- });
+ if (this.loggedIn) {
+ this._userService.getUserFromSessionStorageRequest().subscribe({
+ next: (res: object) => {
+ Object.assign(this.user, res);
+ },
+ });
+ }
}
goToProfile(): void {
diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts
index c4d64ed..c05bd10 100644
--- a/src/app/components/post/post.component.ts
+++ b/src/app/components/post/post.component.ts
@@ -103,17 +103,19 @@ export class PostComponent implements OnInit, AfterViewInit {
}
ngAfterViewInit(): void {
- this._ratingServe.getRatingByUserAndPostWithSessionStorageRequest(Guid.parse(this.paramId)).subscribe({
- next: (x: object) => {
- if (!x) {
- return;
- }
+ if (this.loggedIn) {
+ this._ratingServe.getRatingByUserAndPostWithSessionStorageRequest(Guid.parse(this.paramId)).subscribe({
+ next: (x: object) => {
+ if (!x) {
+ return;
+ }
- const isLike: boolean = Object.values(x)[3];
+ const isLike: boolean = Object.values(x)[3];
- this.changeColorOfVoteButton(isLike, !isLike);
- }
- });
+ this.changeColorOfVoteButton(isLike, !isLike);
+ }
+ });
+ }
this._defaultShareBtnInnerHTML = this.shareBtn.nativeElement.innerHTML;
}