Pass nicknames instead of ids to user links from mod log
This commit is contained in:
parent
c2e80fb063
commit
7cac1c7159
2 changed files with 9 additions and 27 deletions
|
@ -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>'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue