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-teaser
|
||||||
:post="post"
|
:post="post"
|
||||||
:width="{ base: '100%', md: '100%', xl: '50%' }"
|
:width="{ base: '100%', md: '100%', xl: '50%' }"
|
||||||
@removePostFromList="removePostFromList(post, posts)"
|
@removePostFromList="posts = removePostFromList(post, posts)"
|
||||||
@pinPost="pinPost(post, refetchPostList)"
|
@pinPost="pinPost(post, refetchPostList)"
|
||||||
@unpinPost="unpinPost(post, refetchPostList)"
|
@unpinPost="unpinPost(post, refetchPostList)"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -3,11 +3,9 @@ import PostMutations from '~/graphql/PostMutations'
|
|||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
removePostFromList(deletedPost, posts) {
|
removePostFromList(deletedPost, posts) {
|
||||||
// Wolle this.posts = this.posts.filter((post) => {
|
return posts.filter((post) => {
|
||||||
posts = posts.filter((post) => {
|
|
||||||
return post.id !== deletedPost.id
|
return post.id !== deletedPost.id
|
||||||
})
|
})
|
||||||
return posts
|
|
||||||
},
|
},
|
||||||
pinPost(post, refetchPostList = () => {}) {
|
pinPost(post, refetchPostList = () => {}) {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
@ -19,9 +17,7 @@ export default {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$toast.success(this.$t('post.menu.pinnedSuccessfully'))
|
this.$toast.success(this.$t('post.menu.pinnedSuccessfully'))
|
||||||
// Wolle this.resetPostList()
|
|
||||||
refetchPostList()
|
refetchPostList()
|
||||||
// Wolle this.$apollo.queries.Post.refetch()
|
|
||||||
})
|
})
|
||||||
.catch((error) => this.$toast.error(error.message))
|
.catch((error) => this.$toast.error(error.message))
|
||||||
},
|
},
|
||||||
@ -35,9 +31,7 @@ export default {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$toast.success(this.$t('post.menu.unpinnedSuccessfully'))
|
this.$toast.success(this.$t('post.menu.unpinnedSuccessfully'))
|
||||||
// Wolle this.resetPostList()
|
|
||||||
refetchPostList()
|
refetchPostList()
|
||||||
// Wolle this.$apollo.queries.Post.refetch()
|
|
||||||
})
|
})
|
||||||
.catch((error) => this.$toast.error(error.message))
|
.catch((error) => this.$toast.error(error.message))
|
||||||
},
|
},
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
>
|
>
|
||||||
<post-teaser
|
<post-teaser
|
||||||
:post="post"
|
:post="post"
|
||||||
@removePostFromList="removePostFromList(post, posts)"
|
@removePostFromList="posts = removePostFromList(post, posts)"
|
||||||
@pinPost="pinPost(post, refetchPostList)"
|
@pinPost="pinPost(post, refetchPostList)"
|
||||||
@unpinPost="unpinPost(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 MasonryGridItem from '~/components/MasonryGrid/MasonryGridItem.vue'
|
||||||
import { mapGetters, mapMutations } from 'vuex'
|
import { mapGetters, mapMutations } from 'vuex'
|
||||||
import { filterPosts } from '~/graphql/PostQuery.js'
|
import { filterPosts } from '~/graphql/PostQuery.js'
|
||||||
// Wolle import PostMutations from '~/graphql/PostMutations'
|
|
||||||
import UpdateQuery from '~/components/utils/UpdateQuery'
|
import UpdateQuery from '~/components/utils/UpdateQuery'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -162,11 +161,6 @@ export default {
|
|||||||
updateQuery: UpdateQuery(this, { $state, pageKey: 'Post' }),
|
updateQuery: UpdateQuery(this, { $state, pageKey: 'Post' }),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// Wolle deletePost(deletedPost) {
|
|
||||||
// this.posts = this.posts.filter((post) => {
|
|
||||||
// return post.id !== deletedPost.id
|
|
||||||
// })
|
|
||||||
// },
|
|
||||||
resetPostList() {
|
resetPostList() {
|
||||||
this.offset = 0
|
this.offset = 0
|
||||||
this.posts = []
|
this.posts = []
|
||||||
@ -176,32 +170,6 @@ export default {
|
|||||||
this.resetPostList()
|
this.resetPostList()
|
||||||
this.$apollo.queries.Post.refetch()
|
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: {
|
apollo: {
|
||||||
Post: {
|
Post: {
|
||||||
|
|||||||
@ -27,9 +27,9 @@
|
|||||||
<post-teaser
|
<post-teaser
|
||||||
:post="relatedPost"
|
:post="relatedPost"
|
||||||
:width="{ base: '100%', lg: 1 }"
|
:width="{ base: '100%', lg: 1 }"
|
||||||
@removePostFromList="removePostFromList(relatedPost, post.relatedContributions)"
|
@removePostFromList="post.relatedContributions = removePostFromList(relatedPost, post.relatedContributions)"
|
||||||
@pinPost="pinPost(relatedPost)"
|
@pinPost="pinPost(relatedPost, refetchPostList)"
|
||||||
@unpinPost="unpinPost(relatedPost)"
|
@unpinPost="unpinPost(relatedPost, refetchPostList)"
|
||||||
/>
|
/>
|
||||||
</masonry-grid-item>
|
</masonry-grid-item>
|
||||||
</masonry-grid>
|
</masonry-grid>
|
||||||
@ -68,11 +68,9 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// Wolle removePostFromList(deletedPost) {
|
refetchPostList() {
|
||||||
// this.post.relatedContributions = this.post.relatedContributions.filter((contribution) => {
|
this.$apollo.queries.Post.refetch()
|
||||||
// return contribution.id !== deletedPost.id
|
},
|
||||||
// })
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
Post: {
|
Post: {
|
||||||
|
|||||||
@ -199,7 +199,7 @@
|
|||||||
<post-teaser
|
<post-teaser
|
||||||
:post="post"
|
:post="post"
|
||||||
:width="{ base: '100%', md: '100%', xl: '50%' }"
|
:width="{ base: '100%', md: '100%', xl: '50%' }"
|
||||||
@removePostFromList="removePostFromList(post, posts)"
|
@removePostFromList="posts = removePostFromList(post, posts)"
|
||||||
@pinPost="pinPost(post, refetchPostList)"
|
@pinPost="pinPost(post, refetchPostList)"
|
||||||
@unpinPost="unpinPost(post, refetchPostList)"
|
@unpinPost="unpinPost(post, refetchPostList)"
|
||||||
/>
|
/>
|
||||||
@ -341,11 +341,6 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// Wolle removePostFromList(deletedPost) {
|
|
||||||
// this.posts = this.posts.filter((post) => {
|
|
||||||
// return post.id !== deletedPost.id
|
|
||||||
// })
|
|
||||||
// },
|
|
||||||
handleTab(tab) {
|
handleTab(tab) {
|
||||||
if (this.tabActive !== tab) {
|
if (this.tabActive !== tab) {
|
||||||
this.tabActive = tab
|
this.tabActive = tab
|
||||||
@ -420,32 +415,6 @@ export default {
|
|||||||
this.$apollo.queries.User.refetch()
|
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 }) {
|
optimisticFollow({ followedByCurrentUser }) {
|
||||||
/*
|
/*
|
||||||
* Note: followedByCountStartValue is updated to avoid counting from 0 when follow/unfollow
|
* Note: followedByCountStartValue is updated to avoid counting from 0 when follow/unfollow
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user