summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLouis <6653109+artonge@users.noreply.github.com>2023-04-05 11:43:22 +0200
committerGitHub <noreply@github.com>2023-04-05 11:43:22 +0200
commite4e04213d6a57b44323c126a49995f906c2d8c95 (patch)
treef931c4012c4f846548f3badca45c58815554e7d1 /src
parenteac9f58f414ed5cfc377bfb52ec4126432001e4d (diff)
parenteef4ae481479a60bf09179718c321b2e839f6523 (diff)
Merge pull request #1713 from nextcloud/artonge/feat/auto_mention_account_on_reply
Auto mention the recipient when replying to a status
Diffstat (limited to 'src')
-rw-r--r--src/components/Composer/Composer.vue31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/components/Composer/Composer.vue b/src/components/Composer/Composer.vue
index a1ee329f..0040df8d 100644
--- a/src/components/Composer/Composer.vue
+++ b/src/components/Composer/Composer.vue
@@ -278,27 +278,42 @@ export default {
return true
}
- return this.statusContent.length !== 0 && this.statusContent !== '<br>'
+ return !this.statusIsEmpty
+ },
+ /** @return {boolean} */
+ statusIsEmpty() {
+ return this.statusContent.length === 0 || this.statusContent === '<br>'
},
},
mounted() {
- this.$root.$on('composer-reply', (data) => {
+ this.$root.$on('composer-reply', (/** @type {import('../../types/Mastodon.js').Status} */data) => {
this.replyTo = data
+ this.prefillMessageWithMention(data.account)
this.visibility = data.visibility
})
if (this.initialMention !== null) {
+ this.prefillMessageWithMention(this.initialMention)
+ }
+ },
+ methods: {
+ /**
+ * @param {import('../../types/Mastodon.js').Account} account
+ */
+ prefillMessageWithMention(account) {
+ if (!this.statusIsEmpty) {
+ return
+ }
+
this.$refs.composerInput.innerHTML = `
<span class="mention" contenteditable="false">
- <a href="${this.initialMention.url}" target="_blank">
- <img src="${!this.initialMention.acct.includes('@') ? generateUrl(`/avatar/${this.initialMention.username}/32`) : generateUrl(`apps/social/api/v1/global/actor/avatar?id=${this.initialMention.acct}`)}"/>
- @${this.initialMention.acct}
+ <a href="${account.url}" target="_blank">
+ <img src="${!account.acct.includes('@') ? generateUrl(`/avatar/${account.username}/32`) : generateUrl(`apps/social/api/v1/global/actor/avatar?id=${account.acct}`)}"/>
+ @${account.acct}
</a>
</span>&nbsp;`
this.updateStatusContent()
- }
- },
- methods: {
+ },
updateStatusContent() {
this.statusContent = this.$refs.composerInput.innerHTML
},