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.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());

@ -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[]
}

@ -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 {

Loading…
Cancel
Save