From 7cac1c7159f3cd3aba59a4478b96e42db319690e Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 2 Dec 2020 23:42:44 +0300 Subject: [PATCH] Pass nicknames instead of ids to user links from mod log --- src/views/moderation_log/LogEntryMessage.vue | 22 +++++--------------- src/views/moderation_log/UserLink.vue | 14 ++++--------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/views/moderation_log/LogEntryMessage.vue b/src/views/moderation_log/LogEntryMessage.vue index ede85aa2..cf5ab63e 100644 --- a/src/views/moderation_log/LogEntryMessage.vue +++ b/src/views/moderation_log/LogEntryMessage.vue @@ -38,28 +38,16 @@ export default { } }, computed: { - // logEntryMessage() { - // if (!this.actor.nickname) { - // return this.message - // } else { - // return this.message.split(this.actor.nickname).length > 2 - // ? this.message.split(this.actor.nickname)[1].concat(this.actor.nickname) - // : this.message.split(this.actor.nickname)[1] - // } - // }, // logEntryMessageWithoutId() { // return this.logEntryMessage.split(`#${this.subject.id}`) // }, processedHtml() { - const html = this.message.replace(/\@[\S]+/g, ``) + const html = [...this.message.matchAll(/\@(?([\w-]+))/g)].map(res => res.groups.nickname) + .reduce((acc, nickname) => { + return acc.replace(`@${nickname}`, ``) + }, this.message) return { - template: '
' + html + '
', - props: { - actor: { - type: null, - default: () => { return this.actor } - } - } + template: '
' + html + '
' } } } diff --git a/src/views/moderation_log/UserLink.vue b/src/views/moderation_log/UserLink.vue index 11f92128..cacfb1b1 100644 --- a/src/views/moderation_log/UserLink.vue +++ b/src/views/moderation_log/UserLink.vue @@ -1,10 +1,9 @@ @@ -15,14 +14,9 @@ export default { name: 'UserLink', props: { actor: { - type: Object, + type: String, required: true } - }, - methods: { - propertyExists(account, property) { - return account[property] - } } }