From b911ecbb0063944801227c2e559dabed09172a57 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 18 Dec 2019 18:25:40 +0100 Subject: [PATCH] Fix comments URLs Also remote comments were marked as local Signed-off-by: Thomas Citharel --- js/src/components/Comment/Comment.vue | 9 +++++++-- js/src/graphql/comment.ts | 1 + js/src/types/comment.model.ts | 2 ++ lib/mobilizon/events/comment.ex | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/js/src/components/Comment/Comment.vue b/js/src/components/Comment/Comment.vue index 36fa3c5b..debb4f92 100644 --- a/js/src/components/Comment/Comment.vue +++ b/js/src/components/Comment/Comment.vue @@ -13,11 +13,11 @@ {{ comment.actor.name }} @{{ comment.actor.preferredUsername }}@{{ comment.actor.domain }} @{{ comment.actor.preferredUsername }} - + {{ timeago(new Date(comment.updatedAt)) }} - + {{ $t('[deleted]') }} @@ -222,6 +222,11 @@ export default class Comment extends Vue { return `#comment-${this.comment.uuid}`; } + get commentURL(): String { + if (!this.comment.local && this.comment.url) return this.comment.url; + return this.commentId; + } + reportModal() { this.$buefy.modal.open({ parent: this, diff --git a/js/src/graphql/comment.ts b/js/src/graphql/comment.ts index 51e5c0cb..acf28b39 100644 --- a/js/src/graphql/comment.ts +++ b/js/src/graphql/comment.ts @@ -8,6 +8,7 @@ export const COMMENT_FIELDS_FRAGMENT = gql` url, text, visibility, + local, actor { avatar { url diff --git a/js/src/types/comment.model.ts b/js/src/types/comment.model.ts index bed61c4b..0a4f83e1 100644 --- a/js/src/types/comment.model.ts +++ b/js/src/types/comment.model.ts @@ -6,6 +6,7 @@ export interface IComment { uuid?: string; url?: string; text: string; + local: boolean; actor: IActor; inReplyToComment?: IComment; originComment?: IComment; @@ -20,6 +21,7 @@ export class CommentModel implements IComment { actor: IActor = new Actor(); id?: string; text: string = ''; + local: boolean = true; url?: string; uuid?: string; inReplyToComment?: IComment = undefined; diff --git a/lib/mobilizon/events/comment.ex b/lib/mobilizon/events/comment.ex index 8f18b0e7..b3af573d 100644 --- a/lib/mobilizon/events/comment.ex +++ b/lib/mobilizon/events/comment.ex @@ -39,7 +39,8 @@ defmodule Mobilizon.Events.Comment do :in_reply_to_comment_id, :origin_comment_id, :attributed_to_id, - :deleted_at + :deleted_at, + :local ] @attrs @required_attrs ++ @optional_attrs