From 16803e45e673f614b18bb0ec4cd1978b1422a579 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 31 May 2025 10:44:29 +0200 Subject: [PATCH] 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 --- webapp/pages/post/_id/_slug/index.vue | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/webapp/pages/post/_id/_slug/index.vue b/webapp/pages/post/_id/_slug/index.vue index b400ccc32..df94c327b 100644 --- a/webapp/pages/post/_id/_slug/index.vue +++ b/webapp/pages/post/_id/_slug/index.vue @@ -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 },