|
|
@ -1,4 +1,4 @@
|
|
|
|
import { Component, OnInit, Input } from '@angular/core';
|
|
|
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
|
|
|
import { Post } from 'src/app/models/post';
|
|
|
|
import { Post } from 'src/app/models/post';
|
|
|
|
import { FeedService } from 'src/app/services/feed/feed.service';
|
|
|
|
import { FeedService } from 'src/app/services/feed/feed.service';
|
|
|
|
|
|
|
|
|
|
|
@ -10,6 +10,7 @@ import { FeedService } from 'src/app/services/feed/feed.service';
|
|
|
|
export class PostlistComponent implements OnInit {
|
|
|
|
export class PostlistComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
@Input() childPostList: Array<Post>
|
|
|
|
@Input() childPostList: Array<Post>
|
|
|
|
|
|
|
|
@Output() voteEvent = new EventEmitter<boolean>()
|
|
|
|
selectedPost: Post
|
|
|
|
selectedPost: Post
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private feedService: FeedService) { }
|
|
|
|
constructor(private feedService: FeedService) { }
|
|
|
@ -19,18 +20,12 @@ export class PostlistComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
voteUp(pPost: Post){
|
|
|
|
voteUp(pPost: Post){
|
|
|
|
this.feedService.upvote(pPost.id)
|
|
|
|
this.feedService.upvote(pPost.id)
|
|
|
|
this.refresh()
|
|
|
|
this.voteEvent.emit(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
voteDown(pPost: Post){
|
|
|
|
voteDown(pPost: Post){
|
|
|
|
this.feedService.downvote(pPost.id)
|
|
|
|
this.feedService.downvote(pPost.id)
|
|
|
|
this.refresh()
|
|
|
|
this.voteEvent.emit(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refresh() {
|
|
|
|
|
|
|
|
this.feedService.getAllPostsRaw().subscribe(response => {
|
|
|
|
|
|
|
|
this.childPostList = this.feedService.renderAllPosts(response.json())
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|