81 lines
2.1 KiB
TypeScript
81 lines
2.1 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Post } from '../../../model/Post';
|
|
import { AuthService } from '../auth/auth.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class PostService {
|
|
|
|
constructor(private auth: AuthService) { }
|
|
|
|
examplePosts: Array<Post> = new Array<Post>(
|
|
{
|
|
user: {
|
|
username: "Zámbó Jimmy",
|
|
picture: "assets/placeholder-profile-picture.png",
|
|
followed: true
|
|
},
|
|
content: "Bukott diák vagyok én, nem bírom el a szenvedést.",
|
|
image: "assets/placeholder-profile-picture.png",
|
|
likes: 1,
|
|
liked: true
|
|
},
|
|
{
|
|
user: {
|
|
username: "Zámbó Jimmy",
|
|
picture: "assets/placeholder-profile-picture.png",
|
|
followed: true
|
|
},
|
|
content: "Bukott diák vagyok én, nem bírom el a szenvedést.",
|
|
image: "assets/placeholder-profile-picture.png",
|
|
likes: 1,
|
|
liked: true
|
|
},
|
|
{
|
|
user: {
|
|
username: "Zámbó Jimmy",
|
|
picture: "assets/placeholder-profile-picture.png",
|
|
followed: true
|
|
},
|
|
content: "Bukott diák vagyok én, nem bírom el a szenvedést.",
|
|
image: "assets/placeholder-profile-picture.png",
|
|
likes: 1,
|
|
liked: true
|
|
},
|
|
{
|
|
user: {
|
|
username: "Zámbó Jimmy",
|
|
picture: "assets/placeholder-profile-picture.png",
|
|
followed: true
|
|
},
|
|
content: "Bukott diák vagyok én, nem bírom el a szenvedést.",
|
|
image: "assets/placeholder-profile-picture.png",
|
|
likes: 1,
|
|
liked: true
|
|
},
|
|
);
|
|
|
|
getFeed(length: Number, start: Number): Promise<Array<Post>> {
|
|
return new Promise<Array<Post>>((resolve, reject) => {
|
|
// TODO: fetch feed
|
|
this.auth.getToken()
|
|
.then( (token)=> {
|
|
resolve(this.examplePosts);
|
|
})
|
|
.catch( ()=> { reject() });
|
|
});
|
|
}
|
|
|
|
getPosts(username: String, lenght: Number, start: Number) {
|
|
return new Promise<Array<Post>>((resolve, reject) => {
|
|
// TODO: fetch feed
|
|
this.auth.getToken()
|
|
.then( (token)=> {
|
|
resolve(this.examplePosts);
|
|
})
|
|
.catch( ()=> { reject() });
|
|
});
|
|
}
|
|
}
|