Pass nicknames instead of ids to user links from mod log

This commit is contained in:
Angelina Filippova 2020-12-02 23:42:44 +03:00
parent c2e80fb063
commit 7cac1c7159
2 changed files with 9 additions and 27 deletions

View file

@ -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, `<user-link :actor="actor"/>`)
const html = [...this.message.matchAll(/\@(?<nickname>([\w-]+))/g)].map(res => res.groups.nickname)
.reduce((acc, nickname) => {
return acc.replace(`@${nickname}`, `<user-link actor="${nickname}"/>`)
}, this.message)
return {
template: '<div>' + html + '</div>',
props: {
actor: {
type: null,
default: () => { return this.actor }
}
}
template: '<div>' + html + '</div>'
}
}
}

View file

@ -1,10 +1,9 @@
<template>
<router-link
v-if="propertyExists(actor, 'id')"
:to="{ name: 'UsersShow', params: { id: actor.id }}"
:to="{ name: 'UsersShow', params: { id: actor }}"
class="router-link">
<span v-if="propertyExists(actor, 'nickname')" style="font-weight: 600">
@{{ actor.nickname }}
<span style="font-weight: 600;margin-right: -3px;">
@{{ actor }}
</span>
</router-link>
</template>
@ -15,14 +14,9 @@ export default {
name: 'UserLink',
props: {
actor: {
type: Object,
type: String,
required: true
}
},
methods: {
propertyExists(account, property) {
return account[property]
}
}
}
</script>