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> <button id="tab-login" routerLink="/login" *ngIf="loggedIn != true">Login</button>
<div id="dropdown" *ngIf="loggedIn"> <div id="dropdown" *ngIf="loggedIn">
<div> <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> <span>{{username}}</span>
</div> </div>
<div id="dropdown-content" *ngIf="dropdownShown"> <div id="dropdown-content" *ngIf="dropdownShown">

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

@ -1,7 +1,7 @@
<div id="postinput"> <div id="postinput">
<textarea #content id='input' placeholder="Post something ..." rows='3' wrap="soft"></textarea> <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="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>
<div id='completeFeed'> <div id='completeFeed'>
<div id='feedchooser'> <div id='feedchooser'>

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

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

Loading…
Cancel
Save