mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Implement mixins for delete, pin, unpin post in lists, done
This commit is contained in:
parent
c91c9e263f
commit
bcd98c793c
@ -45,7 +45,7 @@
|
||||
<post-teaser
|
||||
:post="post"
|
||||
:width="{ base: '100%', md: '100%', xl: '50%' }"
|
||||
@removePostFromList="removePostFromList(post, posts)"
|
||||
@removePostFromList="posts = removePostFromList(post, posts)"
|
||||
@pinPost="pinPost(post, refetchPostList)"
|
||||
@unpinPost="unpinPost(post, refetchPostList)"
|
||||
/>
|
||||
|
||||
@ -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))
|
||||
},
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
>
|
||||
<post-teaser
|
||||
:post="post"
|
||||
@removePostFromList="removePostFromList(post, posts)"
|
||||
@removePostFromList="posts = removePostFromList(post, posts)"
|
||||
@pinPost="pinPost(post, refetchPostList)"
|
||||
@unpinPost="unpinPost(post, refetchPostList)"
|
||||
/>
|
||||
@ -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: {
|
||||
|
||||
@ -27,9 +27,9 @@
|
||||
<post-teaser
|
||||
:post="relatedPost"
|
||||
:width="{ base: '100%', lg: 1 }"
|
||||
@removePostFromList="removePostFromList(relatedPost, post.relatedContributions)"
|
||||
@pinPost="pinPost(relatedPost)"
|
||||
@unpinPost="unpinPost(relatedPost)"
|
||||
@removePostFromList="post.relatedContributions = removePostFromList(relatedPost, post.relatedContributions)"
|
||||
@pinPost="pinPost(relatedPost, refetchPostList)"
|
||||
@unpinPost="unpinPost(relatedPost, refetchPostList)"
|
||||
/>
|
||||
</masonry-grid-item>
|
||||
</masonry-grid>
|
||||
@ -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: {
|
||||
|
||||
@ -199,7 +199,7 @@
|
||||
<post-teaser
|
||||
:post="post"
|
||||
:width="{ base: '100%', md: '100%', xl: '50%' }"
|
||||
@removePostFromList="removePostFromList(post, posts)"
|
||||
@removePostFromList="posts = removePostFromList(post, posts)"
|
||||
@pinPost="pinPost(post, refetchPostList)"
|
||||
@unpinPost="unpinPost(post, refetchPostList)"
|
||||
/>
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user