fixed user.ts

master
Max 5 years ago
parent 1f11973481
commit ef0f26fdcc

@ -34,7 +34,7 @@ export class FeedComponent implements OnInit {
this.data.currentUserInfo.subscribe(user => { this.data.currentUserInfo.subscribe(user => {
this.user = user; this.user = user;
this.loggedIn = user.loggedIn; this.loggedIn = user.loggedIn;
this.userId = user.userID; if(this.loggedIn) this.userId = user.userID;
}); });
this.feedService.getAllPostsRawByUserId(this.userId).subscribe(response => { this.feedService.getAllPostsRawByUserId(this.userId).subscribe(response => {
this.feedNew = this.feedService.renderAllPosts(response.json()); this.feedNew = this.feedService.renderAllPosts(response.json());

@ -1,15 +1,15 @@
export class User { export class User {
constructor( loggedIn : boolean
public userID: number, userID : number
public loggedIn: boolean, username : string
public username: string, handle : string
public handle: string, email : string
public email: string, points : number
public points: number, level : number
public level: number,
public friendIDs: number[], friendIDs : number[]
public groupIDs: number[], groupIDs : number[]
public chatIDs: number[], chatIDs : number[]
public requestIDs: number[],
) {} requestIDs : number[]
} }

@ -33,23 +33,22 @@ export class LoginService {
this.router.navigateByUrl(''); this.router.navigateByUrl('');
} }
public updateUserInfo(response: any) { public updateUserInfo(response : any){
const loginData = response.data.login; const user: User = new User();
const user: User = new User( user.loggedIn = true;
loginData.login.id, user.userID = response.data.login.id;
true, user.username = response.data.login.name;
loginData.name, user.handle = response.data.login.handle;
loginData.handle, user.email = response.data.login.email;
loginData.email, user.points = response.data.login.points;
loginData.points, user.level = response.data.login.level;
loginData.level, user.friendIDs = response.data.login.friends;
loginData.friends, user.groupIDs = response.data.login.groups;
loginData.groups, user.chatIDs = response.data.login.chats;
loginData.chats, user.requestIDs = response.data.login.requests;
loginData.requests,
);
this.data.changeUserInfo(user); this.data.changeUserInfo(user)
} }
public buildJson(login: Login): any { public buildJson(login: Login): any {

Loading…
Cancel
Save