From b45fd51d150d41645b33c72ae8c69f15e9bf0e94 Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Fri, 18 Oct 2019 00:13:01 +0200 Subject: [PATCH] Pin post on user profile as well --- webapp/pages/profile/_id/_slug.vue | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue index b5ea148c2..571d6bee7 100644 --- a/webapp/pages/profile/_id/_slug.vue +++ b/webapp/pages/profile/_id/_slug.vue @@ -234,6 +234,8 @@ :post="post" :width="{ base: '100%', md: '100%', xl: '50%' }" @removePostFromList="removePostFromList" + @pinPost="pinPost" + @unpinPost="unpinPost" /> @@ -282,6 +284,7 @@ import MasonryGridItem from '~/components/MasonryGrid/MasonryGridItem.vue' import { filterPosts } from '~/graphql/PostQuery' import UserQuery from '~/graphql/User' import { Block, Unblock } from '~/graphql/settings/BlockedUsers' +import PostMutations from '~/graphql/PostMutations' const tabToFilterMapping = ({ tab, id }) => { return { @@ -412,6 +415,32 @@ export default { this.resetPostList() this.$apollo.queries.Post.refetch() }, + 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)) + }, optimisticFollow({ followedByCurrentUser }) { /* * Note: followedByCountStartValue is updated to avoid counting from 0 when follow/unfollow