diff options
author | Louis <6653109+artonge@users.noreply.github.com> | 2023-04-05 11:43:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-05 11:43:22 +0200 |
commit | e4e04213d6a57b44323c126a49995f906c2d8c95 (patch) | |
tree | f931c4012c4f846548f3badca45c58815554e7d1 /src | |
parent | eac9f58f414ed5cfc377bfb52ec4126432001e4d (diff) | |
parent | eef4ae481479a60bf09179718c321b2e839f6523 (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.vue | 31 |
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> ` this.updateStatusContent() - } - }, - methods: { + }, updateStatusContent() { this.statusContent = this.$refs.composerInput.innerHTML }, |