From bcd98c793cbe531d655e54a6d938d6c8b64902df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 8 Oct 2020 15:24:06 +0200 Subject: [PATCH] Implement mixins for delete, pin, unpin post in lists, done --- .../features/SearchResults/SearchResults.vue | 2 +- webapp/mixins/postListActions.js | 8 +---- webapp/pages/index.vue | 34 +------------------ webapp/pages/post/_id/_slug/more-info.vue | 14 ++++---- webapp/pages/profile/_id/_slug.vue | 33 +----------------- 5 files changed, 10 insertions(+), 81 deletions(-) diff --git a/webapp/components/_new/features/SearchResults/SearchResults.vue b/webapp/components/_new/features/SearchResults/SearchResults.vue index bede9bed5..b37534510 100644 --- a/webapp/components/_new/features/SearchResults/SearchResults.vue +++ b/webapp/components/_new/features/SearchResults/SearchResults.vue @@ -45,7 +45,7 @@ diff --git a/webapp/mixins/postListActions.js b/webapp/mixins/postListActions.js index dada46428..8fbadc947 100644 --- a/webapp/mixins/postListActions.js +++ b/webapp/mixins/postListActions.js @@ -3,11 +3,9 @@ import PostMutations from '~/graphql/PostMutations' export default { methods: { removePostFromList(deletedPost, posts) { - // Wolle this.posts = this.posts.filter((post) => { - posts = posts.filter((post) => { + return posts.filter((post) => { return post.id !== deletedPost.id }) - return posts }, pinPost(post, refetchPostList = () => {}) { this.$apollo @@ -19,9 +17,7 @@ export default { }) .then(() => { this.$toast.success(this.$t('post.menu.pinnedSuccessfully')) - // Wolle this.resetPostList() refetchPostList() - // Wolle this.$apollo.queries.Post.refetch() }) .catch((error) => this.$toast.error(error.message)) }, @@ -35,9 +31,7 @@ export default { }) .then(() => { this.$toast.success(this.$t('post.menu.unpinnedSuccessfully')) - // Wolle this.resetPostList() refetchPostList() - // Wolle this.$apollo.queries.Post.refetch() }) .catch((error) => this.$toast.error(error.message)) }, diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index 84f5f22ac..7f7ec2278 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -28,7 +28,7 @@ > @@ -73,7 +73,6 @@ import MasonryGrid from '~/components/MasonryGrid/MasonryGrid.vue' import MasonryGridItem from '~/components/MasonryGrid/MasonryGridItem.vue' import { mapGetters, mapMutations } from 'vuex' import { filterPosts } from '~/graphql/PostQuery.js' -// Wolle import PostMutations from '~/graphql/PostMutations' import UpdateQuery from '~/components/utils/UpdateQuery' export default { @@ -162,11 +161,6 @@ export default { updateQuery: UpdateQuery(this, { $state, pageKey: 'Post' }), }) }, - // Wolle deletePost(deletedPost) { - // this.posts = this.posts.filter((post) => { - // return post.id !== deletedPost.id - // }) - // }, resetPostList() { this.offset = 0 this.posts = [] @@ -176,32 +170,6 @@ export default { this.resetPostList() this.$apollo.queries.Post.refetch() }, - // Wolle pinPost(post) { - // this.$apollo - // .mutate({ - // mutation: PostMutations().pinPost, - // variables: { id: post.id }, - // }) - // .then(() => { - // this.$toast.success(this.$t('post.menu.pinnedSuccessfully')) - // this.resetPostList() - // this.$apollo.queries.Post.refetch() - // }) - // .catch((error) => this.$toast.error(error.message)) - // }, - // unpinPost(post) { - // this.$apollo - // .mutate({ - // mutation: PostMutations().unpinPost, - // variables: { id: post.id }, - // }) - // .then(() => { - // this.$toast.success(this.$t('post.menu.unpinnedSuccessfully')) - // this.resetPostList() - // this.$apollo.queries.Post.refetch() - // }) - // .catch((error) => this.$toast.error(error.message)) - // }, }, apollo: { Post: { diff --git a/webapp/pages/post/_id/_slug/more-info.vue b/webapp/pages/post/_id/_slug/more-info.vue index c5349f630..b511cdb30 100644 --- a/webapp/pages/post/_id/_slug/more-info.vue +++ b/webapp/pages/post/_id/_slug/more-info.vue @@ -27,9 +27,9 @@ @@ -68,11 +68,9 @@ export default { }, }, methods: { - // Wolle removePostFromList(deletedPost) { - // this.post.relatedContributions = this.post.relatedContributions.filter((contribution) => { - // return contribution.id !== deletedPost.id - // }) - // }, + refetchPostList() { + this.$apollo.queries.Post.refetch() + }, }, apollo: { Post: { diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue index 238458ba7..ccc5b409d 100644 --- a/webapp/pages/profile/_id/_slug.vue +++ b/webapp/pages/profile/_id/_slug.vue @@ -199,7 +199,7 @@ @@ -341,11 +341,6 @@ export default { }, }, methods: { - // Wolle removePostFromList(deletedPost) { - // this.posts = this.posts.filter((post) => { - // return post.id !== deletedPost.id - // }) - // }, handleTab(tab) { if (this.tabActive !== tab) { this.tabActive = tab @@ -420,32 +415,6 @@ export default { this.$apollo.queries.User.refetch() } }, - // Wolle pinPost(post) { - // this.$apollo - // .mutate({ - // mutation: PostMutations().pinPost, - // variables: { id: post.id }, - // }) - // .then(() => { - // this.$toast.success(this.$t('post.menu.pinnedSuccessfully')) - // this.resetPostList() - // this.$apollo.queries.profilePagePosts.refetch() - // }) - // .catch((error) => this.$toast.error(error.message)) - // }, - // Wolle unpinPost(post) { - // this.$apollo - // .mutate({ - // mutation: PostMutations().unpinPost, - // variables: { id: post.id }, - // }) - // .then(() => { - // this.$toast.success(this.$t('post.menu.unpinnedSuccessfully')) - // this.resetPostList() - // this.$apollo.queries.profilePagePosts.refetch() - // }) - // .catch((error) => this.$toast.error(error.message)) - // }, optimisticFollow({ followedByCurrentUser }) { /* * Note: followedByCountStartValue is updated to avoid counting from 0 when follow/unfollow