Insert mentions automatically into reply content

This commit is contained in:
silverpill 2022-02-13 22:32:54 +00:00
parent 001a578eb9
commit 968ebe07b2

View file

@ -92,6 +92,7 @@ import { Prop } from "vue-property-decorator"
import { import {
Visibility, Visibility,
VISIBILITY_MAP, VISIBILITY_MAP,
Mention,
Post, Post,
createPost, createPost,
Attachment, Attachment,
@ -132,8 +133,8 @@ export default class PostEditor extends Vue {
private store = setup(() => { private store = setup(() => {
const { currentUser, ensureAuthToken } = useCurrentUser() const { currentUser, ensureAuthToken } = useCurrentUser()
const { instance } = useInstanceInfo() const { instance, getActorAddress } = useInstanceInfo()
return { currentUser, ensureAuthToken, instance } return { currentUser, ensureAuthToken, instance, getActorAddress }
}) })
get author(): User | null { get author(): User | null {
@ -141,6 +142,16 @@ export default class PostEditor extends Vue {
} }
created() { created() {
if (this.inReplyTo) {
const mentions: Mention[] = [
this.inReplyTo.account,
...this.inReplyTo.mentions,
]
this.content = mentions
.filter(mention => mention.id !== this.store.currentUser?.id)
.map(mention => "@" + this.store.getActorAddress(mention))
.join(" ")
}
if (this.inReplyTo && this.inReplyTo.visibility !== Visibility.Public) { if (this.inReplyTo && this.inReplyTo.visibility !== Visibility.Public) {
this.visibility = Visibility.Direct this.visibility = Visibility.Direct
} }