fix broken observe on post (#8610)

Due to missing tests & problematic refactoring, posts could no longer be
observed and the new observe state beeing indicated without reloading
the page.

This reverts parts of
https://github.com/Ocelot-Social-Community/Ocelot-Social/pull/8598 to
fix the problem
This commit is contained in:
Ulf Gebhardt 2025-05-31 10:44:29 +02:00 committed by GitHub
parent 4b3a26d517
commit 16803e45e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -167,6 +167,7 @@ import {
} from '~/components/utils/PostHelpers'
import PostQuery from '~/graphql/PostQuery'
import { groupQuery } from '~/graphql/groups'
import PostMutations from '~/graphql/PostMutations'
import links from '~/constants/links.js'
import GetCategories from '~/mixins/getCategoriesMixin.js'
import postListActions from '~/mixins/postListActions'
@ -308,6 +309,24 @@ export default {
this.post.isObservedByMe = comment.isPostObservedByMe
this.post.observingUsersCount = comment.postObservingUsersCount
},
toggleObservePost(postId, value) {
this.$apollo
.mutate({
mutation: PostMutations().toggleObservePost,
variables: {
value,
id: postId,
},
})
.then(() => {
const message = this.$t(
`post.menu.${value ? 'observedSuccessfully' : 'unobservedSuccessfully'}`,
)
this.$toast.success(message)
this.$apollo.queries.Post.refetch()
})
.catch((error) => this.$toast.error(error.message))
},
toggleNewCommentForm(showNewCommentForm) {
this.showNewCommentForm = showNewCommentForm
},