Feed refresh after posting or voting

master
lampe_n1 5 years ago
parent 3ce7c71f23
commit 9d22c717de

@ -6,7 +6,7 @@
<button id="tab-login" routerLink="/login" *ngIf="loggedIn != true">Login</button>
<div id="dropdown" *ngIf="loggedIn">
<div>
<span (click)="showDropdown()"><i class="fa fa-caret-down" aria-hidden="true"></i></span>
<span id="symbol" (click)="showDropdown()"><i class="fa fa-caret-down" aria-hidden="true"></i></span>
<span>{{username}}</span>
</div>
<div id="dropdown-content" *ngIf="dropdownShown">

@ -46,6 +46,10 @@ h1
margin-left: 2em
span
margin-left: 1em
#symbol
span:hover
background-color: lighten($cHeadPrimaryBackground, 10%)
cursor: pointer
#dropdown-content
position: absolute
background-color: $cHeadPrimaryBackground
@ -54,11 +58,6 @@ h1
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2)
padding: 12px 16px
z-index: 1
div:hover
background-color: lighten($cHeadPrimaryBackground, 10%)
cursor: pointer
#dropdown-content
//display: block
#logoutbutton
@include gridPosition(1, 2, 8, 9)

@ -1,7 +1,7 @@
<div id="postinput">
<textarea #content id='input' placeholder="Post something ..." rows='3' wrap="soft"></textarea>
<button id="attach" type='submit'><span><i class="fa fa-paperclip fa-2x" aria-hidden="true"></i></span></button>
<button id="submit" type='submit' (click)=createPost(content.value)><span><i class="fa fa-send-o fa-2x" aria-hidden="true"></i></span></button>
<button id="submit" type='submit' (click)=createPost(content)><span><i class="fa fa-send-o fa-2x" aria-hidden="true"></i></span></button>
</div>
<div id='completeFeed'>
<div id='feedchooser'>

@ -22,15 +22,18 @@ export class FeedComponent implements OnInit {
ngOnInit() {
this.feedService.getAllPostsRaw().subscribe(response => {
this.feedNew = this.feedService.renderAllPosts(response.json())
console.log(response)
this.parentSelectedPostList = this.feedNew
this.feedMostLiked = this.feedNew
})
}
createPost(pContent: string){
this.feedService.createPost(pContent)
console.log(pContent)
createPost(pElement){
this.feedService.createPost(pElement.value)
pElement.value = ""
this.feedService.getAllPostsRaw().subscribe(response => {
this.feedNew = this.feedService.renderAllPosts(response.json())
this.parentSelectedPostList = this.feedNew
this.feedMostLiked = this.feedNew})
}
showNew() {

@ -19,11 +19,18 @@ export class PostlistComponent implements OnInit {
voteUp(pPost: Post){
this.feedService.upvote(pPost.id)
console.log("UPVOTE", pPost.id)
this.refresh()
}
voteDown(pPost: Post){
this.feedService.downvote(pPost.id)
this.refresh()
}
refresh() {
this.feedService.getAllPostsRaw().subscribe(response => {
this.childPostList = this.feedService.renderAllPosts(response.json())
})
}
}

Loading…
Cancel
Save