diff --git a/src/app/components/feed/feed.component.ts b/src/app/components/feed/feed.component.ts index ca4b875..aa6599e 100644 --- a/src/app/components/feed/feed.component.ts +++ b/src/app/components/feed/feed.component.ts @@ -34,7 +34,7 @@ export class FeedComponent implements OnInit { this.data.currentUserInfo.subscribe(user => { this.user = user; this.loggedIn = user.loggedIn; - this.userId = user.userID; + if(this.loggedIn) this.userId = user.userID; }); this.feedService.getAllPostsRawByUserId(this.userId).subscribe(response => { this.feedNew = this.feedService.renderAllPosts(response.json()); diff --git a/src/app/models/user.ts b/src/app/models/user.ts index 3b073b6..619d6b7 100644 --- a/src/app/models/user.ts +++ b/src/app/models/user.ts @@ -1,15 +1,15 @@ export class User { - constructor( - public userID: number, - public loggedIn: boolean, - public username: string, - public handle: string, - public email: string, - public points: number, - public level: number, - public friendIDs: number[], - public groupIDs: number[], - public chatIDs: number[], - public requestIDs: number[], - ) {} -} + loggedIn : boolean + userID : number + username : string + handle : string + email : string + points : number + level : number + + friendIDs : number[] + groupIDs : number[] + chatIDs : number[] + + requestIDs : number[] +} \ No newline at end of file diff --git a/src/app/services/login/login.service.ts b/src/app/services/login/login.service.ts index 195b56b..2c73a59 100644 --- a/src/app/services/login/login.service.ts +++ b/src/app/services/login/login.service.ts @@ -33,23 +33,22 @@ export class LoginService { this.router.navigateByUrl(''); } - public updateUserInfo(response: any) { - const loginData = response.data.login; - const user: User = new User( - loginData.login.id, - true, - loginData.name, - loginData.handle, - loginData.email, - loginData.points, - loginData.level, - loginData.friends, - loginData.groups, - loginData.chats, - loginData.requests, - ); + public updateUserInfo(response : any){ + const user: User = new User(); + user.loggedIn = true; + user.userID = response.data.login.id; + user.username = response.data.login.name; + user.handle = response.data.login.handle; + user.email = response.data.login.email; + user.points = response.data.login.points; + user.level = response.data.login.level; + user.friendIDs = response.data.login.friends; + user.groupIDs = response.data.login.groups; + user.chatIDs = response.data.login.chats; + user.requestIDs = response.data.login.requests; - this.data.changeUserInfo(user); + this.data.changeUserInfo(user) + } public buildJson(login: Login): any {