Merge branch 'niklas_dev2' of Software_Engineering_I/greenvironment-frontend into master

master
Niklas_L 5 years ago committed by Gitea
commit 80361a6886

@ -229,8 +229,8 @@ export class ChatService {
} }
getBodyForSendMessage(pchatID: number, pContent: string) { getBodyForSendMessage(pchatID: number, pContent: string) {
const body = {query: `mutation($chatID: ID!, $content: String!) { const body = {query: `mutation($chatId: ID!, $content: String!) {
sendMessage(chatId: $chatID, content: $content) {id} sendMessage(chatId: $chatId, content: $content) {id}
}`, variables: { }`, variables: {
chatId: pchatID, chatId: pchatID,
content: pContent content: pContent

@ -78,7 +78,7 @@ export class FeedService {
let headers = new Headers() let headers = new Headers()
headers.set('Content-Type', 'application/json') headers.set('Content-Type', 'application/json')
this.http.post(url, this.getBodyForGetAllChats()) this.http.post(url, this.getBodyForGetAllPosts())
.subscribe(response => { .subscribe(response => {
this.posts = this.renderAllPosts(response.json()) this.posts = this.renderAllPosts(response.json())
console.log(response) console.log(response)
@ -92,10 +92,10 @@ export class FeedService {
let headers = new Headers() let headers = new Headers()
headers.set('Content-Type', 'application/json') headers.set('Content-Type', 'application/json')
return this.http.post(url, this.getBodyForGetAllChats()) return this.http.post(url, this.getBodyForGetAllPosts())
} }
getBodyForGetAllChats() { getBodyForGetAllPosts() {
const body = {query: `query { const body = {query: `query {
getPosts (first: 1000, offset: 0) {id, content, htmlContent, upvotes, downvotes, author{name, handle, id}, createdAt} getPosts (first: 1000, offset: 0) {id, content, htmlContent, upvotes, downvotes, author{name, handle, id}, createdAt}
}` }`
@ -113,7 +113,7 @@ export class FeedService {
let upvotes: number = post.upvotes let upvotes: number = post.upvotes
let downvotes: number = post.downvotes let downvotes: number = post.downvotes
let author = new Author(post.author.id, post.author.name, post.author.handle) let author = new Author(post.author.id, post.author.name, post.author.handle)
let date = post.createdAt let date = new Date(post.createdAt).toDateString()
posts.push(new Post(id, content, htmlContent, upvotes, downvotes, date, author)) posts.push(new Post(id, content, htmlContent, upvotes, downvotes, date, author))
} }

Loading…
Cancel
Save