diff --git a/src/components/chat_view/chat_view.vue b/src/components/chat_view/chat_view.vue index 146d7d043..463171f2d 100644 --- a/src/components/chat_view/chat_view.vue +++ b/src/components/chat_view/chat_view.vue @@ -85,9 +85,13 @@ mention) + replyTo: String, // id of the post replying to + repliedUser: Object, // user object replying to + attentions: Array, // list of users mentioned + repliedScope: String, // scope of the post replying to + repliedSubject: String, // subject of post replying to + profileMention: Boolean, // is mentioning a user (used in profile page -> mention) // Draft stuff hideDraft: Boolean, // Disable drafts functionality @@ -215,12 +219,12 @@ const PostStatusForm = { mounted() { this.resize(this.$refs.textarea) - if (this.repliedStatus) { + if (this.replyTo) { const textLength = this.$refs.textarea.value.length this.$refs.textarea.setSelectionRange(textLength, textLength) } - if (this.repliedStatus || this.autoFocus) { + if (this.replyTo || this.autoFocus) { this.$refs.textarea.focus() } }, @@ -238,9 +242,9 @@ const PostStatusForm = { // Composing stuff statusType() { - if (this.repliedStatus) { + if (this.replyTo) { return 'reply' - } else if (this.profileMention) { + } else if (this.profileMention && this.repliedUser?.id) { return 'mention' } else if (this.statusId) { return 'edit' @@ -249,10 +253,10 @@ const PostStatusForm = { } }, refId() { - if (this.repliedStatus) { - return this.repliedStatus.id - } else if (this.profileMention) { - return this.profileMention.id + if (this.replyTo) { + return this.replyTo + } else if (this.profileMention && this.repliedUser?.id) { + return this.profileMention && this.repliedUser?.id } else if (this.statusId) { return this.statusId } else { @@ -262,10 +266,9 @@ const PostStatusForm = { mentionsString() { if (this.statusType !== 'reply' && this.statusType !== 'mention') return '' - let allAttentions = [...(this.repliedStatus?.attentions || [])] - const repliedUser = this.repliedStatus?.user || this.profileMention + let allAttentions = [...(this.newStatus.mentions || [])] - if (repliedUser) allAttentions.unshift(repliedUser) + if (this.repliedUser) allAttentions.unshift(this.repliedUser) allAttentions = uniqBy(allAttentions, 'id') allAttentions = reject(allAttentions, { id: this.currentUser.id }) @@ -289,13 +292,11 @@ const PostStatusForm = { mediaDescriptions: {}, } - const scope = (() => { - if (this.repliedStatus) { - if (this.repliedStatus.visibility === 'direct') return 'direct' - if (this.userDefaultScopeCopy) return this.repliedStatus.visibility - } - return this.userDefaultScope - })() + const scope = + (this.repliedScope && this.userDefaultScopeCopy) || + this.repliedScope === 'direct' + ? this.repliedScope + : this.userDefaultScope const preset = this.$route.query.message const statusText = preset ?? '' @@ -306,7 +307,7 @@ const PostStatusForm = { defaultNewStatus.status = this.mentionsString + statusText } - defaultNewStatus.mentions = this.mentionsString + defaultNewStatus.mentions = this.attentions defaultNewStatus.spoilerText = this.repliedSubjectString ?? '' defaultNewStatus.nsfw = this.userDefaultSensitive defaultNewStatus.visibility = scope @@ -326,12 +327,12 @@ const PostStatusForm = { return !this.hasQuote || !this.newStatus.quote.thread || !this.newStatus.quote.id - ? this.repliedStatus?.id + ? this.replyTo : undefined }, repliedSubjectString() { - if (!this.repliedStatus?.summary) return null - const decodedSummary = ldUnescape(this.repliedStatus.summary) + if (!this.repliedSubject) return null + const decodedSummary = ldUnescape(this.repliedSubject) const behavior = this.mergedConfig.subjectLineBehavior const startsWithRe = decodedSummary.match(/^re[: ]/i) if ((behavior !== 'noop' && startsWithRe) || behavior === 'masto') { @@ -351,7 +352,7 @@ const PostStatusForm = { return this.newStatus.quote !== null }, quotable() { - return this.quotingAvailable && this.repliedStatus?.id + return this.quotingAvailable && this.replyTo }, defaultQuotable() { if ( @@ -362,18 +363,20 @@ const PostStatusForm = { return false } - if (!this.repliedStatus) { + const repliedStatus = + this.$store.state.statuses.allStatusesObject[this.replyTo] + if (!repliedStatus) { return false } if ( - this.repliedStatus.visibility === 'public' || - this.repliedStatus.visibility === 'unlisted' || - this.repliedStatus.visibility === 'local' + repliedStatus.visibility === 'public' || + repliedStatus.visibility === 'unlisted' || + repliedStatus.visibility === 'local' ) { return true - } else if (this.repliedStatus.visibility === 'private') { - return this.repliedStatus.user.id === this.currentUser.id + } else if (repliedStatus.visibility === 'private') { + return repliedStatus.user.id === this.currentUser.id } return false @@ -389,7 +392,7 @@ const PostStatusForm = { if (value) { this.newStatus.quote = {} this.newStatus.quote.thread = value - this.newStatus.quote.id = value ? this.repliedStatus.id : '' + this.newStatus.quote.id = value ? this.replyTo : '' } else { this.newStatus.quote = null } diff --git a/src/components/status/status.js b/src/components/status/status.js index b87acc3d7..fb37a7faf 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -200,7 +200,6 @@ const Status = { ) }, status() { - console.log('s', this.statusoid) if (this.retweet) { return this.statusoid.retweeted_status } else { diff --git a/src/components/status/status.vue b/src/components/status/status.vue index da9fbe7ab..3ddcf4e96 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -546,7 +546,11 @@ ref="postStatusForm" class="reply-body" :closeable="true" - :replied-status="status" + :reply-to="status.id" + :attentions="status.attentions" + :replied-user="status.user" + :replied-scope="status.visibility" + :replied-subject="status.summary" @posted="closeReplyForm" @draft-done="closeReplyForm" @close-accepted="closeReplyForm" diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index 9f6488b34..7c5b2a454 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -491,7 +491,8 @@ export default { }, mentionUser() { usePostStatusStore().openPostStatusModal({ - profileMention: this.user, + profileMention: true, + repliedUser: this.user, }) }, onAvatarClickHandler(e) {