diff --git a/js/src/components/Activity/DiscussionActivityItem.vue b/js/src/components/Activity/DiscussionActivityItem.vue index c05c145fd..33cc9ab4b 100644 --- a/js/src/components/Activity/DiscussionActivityItem.vue +++ b/js/src/components/Activity/DiscussionActivityItem.vue @@ -55,6 +55,7 @@ import RouteName from "../../router/name"; import PopoverActorCard from "../Account/PopoverActorCard.vue"; import ActivityMixin from "../../mixins/activity"; import { mixins } from "vue-class-component"; +import { convertActivity } from "@/services/activity-converter"; @Component({ components: { @@ -67,35 +68,9 @@ export default class DiscussionActivityItem extends mixins(ActivityMixin) { ActivityDiscussionSubject = ActivityDiscussionSubject; get translation(): string | undefined { - switch (this.activity.subject) { - case ActivityDiscussionSubject.DISCUSSION_CREATED: - if (this.isAuthorCurrentActor) { - return "You created the discussion {discussion}."; - } - return "{profile} created the discussion {discussion}."; - case ActivityDiscussionSubject.DISCUSSION_REPLIED: - if (this.isAuthorCurrentActor) { - return "You replied to the discussion {discussion}."; - } - return "{profile} replied to the discussion {discussion}."; - case ActivityDiscussionSubject.DISCUSSION_RENAMED: - if (this.isAuthorCurrentActor) { - return "You renamed the discussion from {old_discussion} to {discussion}."; - } - return "{profile} renamed the discussion from {old_discussion} to {discussion}."; - case ActivityDiscussionSubject.DISCUSSION_ARCHIVED: - if (this.isAuthorCurrentActor) { - return "You archived the discussion {discussion}."; - } - return "{profile} archived the discussion {discussion}."; - case ActivityDiscussionSubject.DISCUSSION_DELETED: - if (this.isAuthorCurrentActor) { - return "You deleted the discussion {discussion}."; - } - return "{profile} deleted the discussion {discussion}."; - default: - return undefined; - } + return convertActivity(this.activity, { + isAuthorCurrentActor: this.isAuthorCurrentActor, + }); } get iconColor(): string | undefined { diff --git a/js/src/components/Activity/EventActivityItem.vue b/js/src/components/Activity/EventActivityItem.vue index 573ee11a7..c5cee603d 100644 --- a/js/src/components/Activity/EventActivityItem.vue +++ b/js/src/components/Activity/EventActivityItem.vue @@ -44,6 +44,7 @@ import { Component } from "vue-property-decorator"; import RouteName from "../../router/name"; import PopoverActorCard from "../Account/PopoverActorCard.vue"; import ActivityMixin from "../../mixins/activity"; +import { convertActivity } from "@/services/activity-converter"; @Component({ components: { @@ -56,36 +57,9 @@ export default class EventActivityItem extends mixins(ActivityMixin) { RouteName = RouteName; get translation(): string | undefined { - switch (this.activity.subject) { - case ActivityEventSubject.EVENT_CREATED: - if (this.isAuthorCurrentActor) { - return "You created the event {event}."; - } - return "The event {event} was created by {profile}."; - case ActivityEventSubject.EVENT_UPDATED: - if (this.isAuthorCurrentActor) { - return "You updated the event {event}."; - } - return "The event {event} was updated by {profile}."; - case ActivityEventSubject.EVENT_DELETED: - if (this.isAuthorCurrentActor) { - return "You deleted the event {event}."; - } - return "The event {event} was deleted by {profile}."; - case ActivityEventCommentSubject.COMMENT_POSTED: - if (this.subjectParams.comment_reply_to) { - if (this.isAuthorCurrentActor) { - return "You replied to a comment on the event {event}."; - } - return "{profile} replied to a comment on the event {event}."; - } - if (this.isAuthorCurrentActor) { - return "You posted a comment on the event {event}."; - } - return "{profile} posted a comment on the event {event}."; - default: - return undefined; - } + return convertActivity(this.activity, { + isAuthorCurrentActor: this.isAuthorCurrentActor, + }); } get iconColor(): string | undefined { diff --git a/js/src/components/Activity/GroupActivityItem.vue b/js/src/components/Activity/GroupActivityItem.vue index d54bf896a..09d0cd496 100644 --- a/js/src/components/Activity/GroupActivityItem.vue +++ b/js/src/components/Activity/GroupActivityItem.vue @@ -77,6 +77,7 @@ import RouteName from "../../router/name"; import PopoverActorCard from "../Account/PopoverActorCard.vue"; import ActivityMixin from "../../mixins/activity"; import { mixins } from "vue-class-component"; +import { convertActivity } from "@/services/activity-converter"; @Component({ components: { @@ -89,20 +90,9 @@ export default class GroupActivityItem extends mixins(ActivityMixin) { ActivityGroupSubject = ActivityGroupSubject; get translation(): string | undefined { - switch (this.activity.subject) { - case ActivityGroupSubject.GROUP_CREATED: - if (this.isAuthorCurrentActor) { - return "You created the group {group}."; - } - return "{profile} created the group {group}."; - case ActivityGroupSubject.GROUP_UPDATED: - if (this.isAuthorCurrentActor) { - return "You updated the group {group}."; - } - return "{profile} updated the group {group}."; - default: - return undefined; - } + return convertActivity(this.activity, { + isAuthorCurrentActor: this.isAuthorCurrentActor, + }); } get iconColor(): string | undefined { diff --git a/js/src/components/Activity/MemberActivityItem.vue b/js/src/components/Activity/MemberActivityItem.vue index c03c21b99..da8b24c17 100644 --- a/js/src/components/Activity/MemberActivityItem.vue +++ b/js/src/components/Activity/MemberActivityItem.vue @@ -42,19 +42,13 @@