From 18cd7c11f1d900e91fdbbcbe3cfdc5a5adb48c33 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 13 Nov 2021 11:46:25 +0100 Subject: [PATCH 1/6] Fix error when determining audience for Discussion Closes #873 Signed-off-by: Thomas Citharel --- lib/federation/activity_pub/audience.ex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/federation/activity_pub/audience.ex b/lib/federation/activity_pub/audience.ex index d412ef36f..2f24035e3 100644 --- a/lib/federation/activity_pub/audience.ex +++ b/lib/federation/activity_pub/audience.ex @@ -3,7 +3,7 @@ defmodule Mobilizon.Federation.ActivityPub.Audience do Tools for calculating content audience """ - alias Mobilizon.{Actors, Events, Share} + alias Mobilizon.{Actors, Discussions, Events, Share} alias Mobilizon.Actors.{Actor, Member} alias Mobilizon.Discussions.{Comment, Discussion} alias Mobilizon.Events.{Event, Participant} @@ -43,8 +43,10 @@ defmodule Mobilizon.Federation.ActivityPub.Audience do %{"to" => [@ap_public], "cc" => []} end - def get_audience(%Comment{discussion: %Discussion{} = discussion}) do - get_audience(discussion) + def get_audience(%Comment{discussion: %Discussion{id: discussion_id}}) do + discussion_id + |> Discussions.get_discussion() + |> get_audience() end def get_audience(%Comment{ From e6b186026d048db6bc152cefa1dc0259d60c88bb Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 13 Nov 2021 11:47:56 +0100 Subject: [PATCH 2/6] Fix a couple of Apollo cache issues Signed-off-by: Thomas Citharel --- .../Discussion/DiscussionComment.vue | 6 +- js/src/views/Discussions/Discussion.vue | 98 +++---------------- 2 files changed, 20 insertions(+), 84 deletions(-) diff --git a/js/src/components/Discussion/DiscussionComment.vue b/js/src/components/Discussion/DiscussionComment.vue index a5bfa10e8..ff8a0f848 100644 --- a/js/src/components/Discussion/DiscussionComment.vue +++ b/js/src/components/Discussion/DiscussionComment.vue @@ -145,8 +145,10 @@ export default class DiscussionComment extends Vue { } updateComment(): void { - this.comment.text = this.updatedComment; - this.$emit("update-comment", this.comment); + this.$emit("update-comment", { + ...this.comment, + text: this.updatedComment, + }); this.toggleEditMode(); } } diff --git a/js/src/views/Discussions/Discussion.vue b/js/src/views/Discussions/Discussion.vue index bbcdf9847..b61457dc7 100644 --- a/js/src/views/Discussions/Discussion.vue +++ b/js/src/views/Discussions/Discussion.vue @@ -154,7 +154,7 @@ import { GraphQLError } from "graphql"; import { DELETE_COMMENT, UPDATE_COMMENT } from "@/graphql/comment"; import RouteName from "../../router/name"; import { IComment } from "../../types/comment.model"; -import { ApolloCache, FetchResult } from "@apollo/client/core"; +import { ApolloCache, FetchResult, gql, Reference } from "@apollo/client/core"; import { mixins } from "vue-class-component"; import GroupMixin from "@/mixins/group"; @@ -310,49 +310,23 @@ export default class Discussion extends mixins(GroupMixin) { variables: { commentId: comment.id, }, - update: ( - store: ApolloCache<{ deleteComment: IComment }>, - { data }: FetchResult - ) => { - if (!data || !data.deleteComment) return; - const discussionData = store.readQuery<{ - discussion: IDiscussion; - }>({ - query: GET_DISCUSSION, - variables: { - slug: this.slug, - page: this.page, - }, - }); - if (!discussionData) return; - const { discussion: discussionCached } = discussionData; - const index = discussionCached.comments.elements.findIndex( - ({ id }) => id === data.deleteComment.id - ); - let discussionUpdated = discussionCached; - if (index > -1) { - const updatedComment = { - ...discussionCached.comments.elements[index], + update: (store: ApolloCache<{ deleteComment: IComment }>) => { + store.writeFragment({ + id: store.identify(comment as unknown as Reference), + fragment: gql` + fragment CommentDeleted on Comment { + deletedAt + actor { + id + } + text + } + `, + data: { deletedAt: new Date(), + text: "", actor: null, - updatedComment: { - text: "", - }, - }; - const elements = [...discussionCached.comments.elements]; - elements.splice(index, 1, updatedComment); - discussionUpdated = { - ...discussionCached, - comments: { - total: discussionCached.comments.total, - elements, - }, - }; - } - store.writeQuery({ - query: GET_DISCUSSION, - variables: { slug: this.slug, page: this.page }, - data: { discussion: discussionUpdated }, + }, }); }, }); @@ -369,20 +343,6 @@ export default class Discussion extends mixins(GroupMixin) { page: this.page, limit: this.COMMENTS_PER_PAGE, }, - updateQuery: (previousResult, { fetchMoreResult }) => { - return { - discussion: { - ...previousResult.discussion, - comments: { - ...fetchMoreResult.discussion.comments, - elements: [ - ...previousResult.discussion.comments.elements, - ...fetchMoreResult.discussion.comments.elements, - ], - }, - }, - }; - }, }); this.hasMoreComments = !this.discussion.comments.elements .map(({ id }) => id) @@ -399,32 +359,6 @@ export default class Discussion extends mixins(GroupMixin) { discussionId: this.discussion.id, title: this.newTitle, }, - update: ( - store: ApolloCache<{ updateDiscussion: IDiscussion }>, - { data }: FetchResult<{ updateDiscussion: IDiscussion }> - ) => { - const discussionData = store.readQuery<{ - discussion: IDiscussion; - }>({ - query: GET_DISCUSSION, - variables: { - slug: this.slug, - page: this.page, - }, - }); - if (discussionData && data?.updateDiscussion) { - store.writeQuery({ - query: GET_DISCUSSION, - variables: { slug: this.slug, page: this.page }, - data: { - discussion: { - ...discussionData.discussion, - title: data?.updateDiscussion.title, - }, - }, - }); - } - }, }); this.editTitleMode = false; } From b1a9c28a9724ee5b06c28b76b800b173987f9707 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 13 Nov 2021 12:33:14 +0100 Subject: [PATCH 3/6] Add closeButtonAriaLabel to everymodal Signed-off-by: Thomas Citharel --- js/src/App.vue | 2 +- js/src/components/Comment/Comment.vue | 4 ++++ js/src/components/Event/EventMetadataList.vue | 6 +++++- .../Event/OrganizerPickerWrapper.vue | 6 +++++- .../Participation/ParticipationSection.vue | 1 + .../views/Account/IdentityPickerWrapper.vue | 6 +++++- js/src/views/Event/Edit.vue | 7 ++++++- js/src/views/Event/Event.vue | 5 +++++ js/src/views/Group/Group.vue | 3 +++ js/src/views/Posts/Post.vue | 8 +++++++- js/src/views/Resources/ResourceFolder.vue | 19 ++++++++++++++++--- js/src/views/Settings/AccountSettings.vue | 1 + 12 files changed, 59 insertions(+), 9 deletions(-) diff --git a/js/src/App.vue b/js/src/App.vue index cafe7ffe1..521346415 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -9,7 +9,7 @@ type="is-danger" :title="$t('Warning').toLocaleUpperCase()" closable - aria-close-label="Close" + :aria-close-label="$t('Close')" >

{{ $t("This is a demonstration site to test Mobilizon.") }} diff --git a/js/src/components/Comment/Comment.vue b/js/src/components/Comment/Comment.vue index 28267be3c..d450f99ed 100644 --- a/js/src/components/Comment/Comment.vue +++ b/js/src/components/Comment/Comment.vue @@ -299,6 +299,10 @@ export default class Comment extends Vue { onConfirm: this.reportComment, outsideDomain: this.comment.actor.domain, }, + // https://github.com/buefy/buefy/pull/3589 + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + closeButtonAriaLabel: this.$t("Close"), }); } diff --git a/js/src/components/Event/EventMetadataList.vue b/js/src/components/Event/EventMetadataList.vue index c43bd70cf..a1ca63100 100644 --- a/js/src/components/Event/EventMetadataList.vue +++ b/js/src/components/Event/EventMetadataList.vue @@ -62,7 +62,11 @@

- +