diff --git a/backend/src/schema/resolvers/users.js b/backend/src/schema/resolvers/users.js
index f0a179028..90bd15822 100644
--- a/backend/src/schema/resolvers/users.js
+++ b/backend/src/schema/resolvers/users.js
@@ -179,6 +179,7 @@ export default {
hasOne: {
invitedBy: '<-[:INVITED]-(related:User)',
disabledBy: '<-[:DISABLED]-(related:User)',
+ location: '-[:IS_IN]->(related:Location)',
},
hasMany: {
followedBy: '<-[:FOLLOWS]-(related:User)',
diff --git a/webapp/components/Comment.vue b/webapp/components/Comment.vue
index 74b3f893c..e4df37693 100644
--- a/webapp/components/Comment.vue
+++ b/webapp/components/Comment.vue
@@ -68,7 +68,6 @@ import ContentMenu from '~/components/ContentMenu'
import ContentViewer from '~/components/Editor/ContentViewer'
import HcEditCommentForm from '~/components/EditCommentForm/EditCommentForm'
import CommentMutations from '~/graphql/CommentMutations'
-import PostQuery from '~/graphql/PostQuery'
export default {
data: function() {
@@ -143,26 +142,14 @@ export default {
},
async deleteCommentCallback() {
try {
- await this.$apollo.mutate({
+ const {
+ data: { DeleteComment },
+ } = await this.$apollo.mutate({
mutation: CommentMutations(this.$i18n).DeleteComment,
variables: { id: this.comment.id },
- update: async store => {
- const data = await store.readQuery({
- query: PostQuery(this.$i18n),
- variables: { id: this.post.id },
- })
-
- const index = data.Post[0].comments.findIndex(
- deletedComment => deletedComment.id === this.comment.id,
- )
- if (index !== -1) {
- data.Post[0].comments.splice(index, 1)
- }
- await store.writeQuery({ query: PostQuery(this.$i18n), data })
- },
})
this.$toast.success(this.$t(`delete.comment.success`))
- this.$emit('deleteComment')
+ this.$emit('deleteComment', DeleteComment)
} catch (err) {
this.$toast.error(err.message)
}
diff --git a/webapp/components/CommentList/CommentList.vue b/webapp/components/CommentList/CommentList.vue
index 2ae670bf4..710607b94 100644
--- a/webapp/components/CommentList/CommentList.vue
+++ b/webapp/components/CommentList/CommentList.vue
@@ -18,11 +18,11 @@
@@ -40,5 +40,12 @@ export default {
props: {
post: { type: Object, default: () => {} },
},
+ methods: {
+ deleteComment(deleted) {
+ this.post.comments = this.post.comments.map(comment => {
+ return comment.id === deleted.id ? deleted : comment
+ })
+ },
+ },
}
diff --git a/webapp/components/PostCard/index.vue b/webapp/components/PostCard/index.vue
index 7c79fe9eb..43f846d89 100644
--- a/webapp/components/PostCard/index.vue
+++ b/webapp/components/PostCard/index.vue
@@ -118,9 +118,11 @@ export default {
methods: {
async deletePostCallback() {
try {
- await this.$apollo.mutate(deletePostMutation(this.post.id))
+ const {
+ data: { DeletePost },
+ } = await this.$apollo.mutate(deletePostMutation(this.post.id))
this.$toast.success(this.$t('delete.contribution.success'))
- this.$emit('removePostFromList')
+ this.$emit('removePostFromList', DeletePost)
} catch (err) {
this.$toast.error(err.message)
}
diff --git a/webapp/graphql/CommentMutations.js b/webapp/graphql/CommentMutations.js
index b772923d4..dd8d1d3a0 100644
--- a/webapp/graphql/CommentMutations.js
+++ b/webapp/graphql/CommentMutations.js
@@ -1,6 +1,7 @@
import gql from 'graphql-tag'
export default i18n => {
+ const lang = i18n.locale().toUpperCase()
return {
CreateComment: gql`
mutation($postId: ID!, $content: String!) {
@@ -55,6 +56,31 @@ export default i18n => {
mutation($id: ID!) {
DeleteComment(id: $id) {
id
+ contentExcerpt
+ content
+ createdAt
+ disabled
+ deleted
+ author {
+ id
+ slug
+ name
+ avatar
+ disabled
+ deleted
+ shoutedCount
+ contributionsCount
+ commentedCount
+ followedByCount
+ followedByCurrentUser
+ location {
+ name: name${lang}
+ }
+ badges {
+ id
+ icon
+ }
+ }
}
}
`,
diff --git a/webapp/graphql/PostQuery.js b/webapp/graphql/PostQuery.js
index d82232fd8..a5415c6cf 100644
--- a/webapp/graphql/PostQuery.js
+++ b/webapp/graphql/PostQuery.js
@@ -128,3 +128,51 @@ export const PostsEmotionsByCurrentUser = () => {
}
`
}
+
+export const relatedContributions = i18n => {
+ const lang = i18n.locale().toUpperCase()
+ return gql`query Post($slug: String!) {
+ Post(slug: $slug) {
+ id
+ title
+ tags {
+ id
+ }
+ categories {
+ id
+ name
+ icon
+ }
+ relatedContributions(first: 2) {
+ id
+ title
+ slug
+ contentExcerpt
+ shoutedCount
+ categories {
+ id
+ name
+ icon
+ }
+ author {
+ id
+ name
+ slug
+ avatar
+ contributionsCount
+ followedByCount
+ followedByCurrentUser
+ commentedCount
+ location {
+ name: name${lang}
+ }
+ badges {
+ id
+ icon
+ }
+ }
+ }
+ shoutedCount
+ }
+ }`
+}
diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue
index 1783007db..a89e1ce76 100644
--- a/webapp/pages/index.vue
+++ b/webapp/pages/index.vue
@@ -20,7 +20,7 @@
@@ -164,9 +164,9 @@ export default {
showMoreContributions() {
this.offset += this.pageSize
},
- deletePost(_index, postId) {
+ deletePost(deletedPost) {
this.posts = this.posts.filter(post => {
- return post.id !== postId
+ return post.id !== deletedPost.id
})
},
},
diff --git a/webapp/pages/post/_id/_slug/more-info.vue b/webapp/pages/post/_id/_slug/more-info.vue
index ab711e101..b05312a0a 100644
--- a/webapp/pages/post/_id/_slug/more-info.vue
+++ b/webapp/pages/post/_id/_slug/more-info.vue
@@ -36,11 +36,11 @@
@@ -50,9 +50,9 @@