From dc49ef9999c97f63291f0799d9435d4c273b7f68 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 4 Jan 2022 20:27:58 -0600 Subject: [PATCH 1/2] ReplyMentions: to.length --> to.size, fix bug replying to self --- app/soapbox/features/compose/components/reply_mentions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/soapbox/features/compose/components/reply_mentions.js b/app/soapbox/features/compose/components/reply_mentions.js index 55c0f95eb..c08e52fd0 100644 --- a/app/soapbox/features/compose/components/reply_mentions.js +++ b/app/soapbox/features/compose/components/reply_mentions.js @@ -23,7 +23,7 @@ class ReplyMentions extends ImmutablePureComponent { render() { const { explicitAddressing, to, isReply } = this.props; - if (!explicitAddressing || !isReply || !to || to.length === 0) { + if (!explicitAddressing || !isReply || !to || to.size === 0) { return null; } @@ -41,4 +41,4 @@ class ReplyMentions extends ImmutablePureComponent { ); } -} \ No newline at end of file +} From 4c66126c01866fc23d696659fb51b59c038d8a5b Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 4 Jan 2022 20:28:49 -0600 Subject: [PATCH 2/2] Explicit addressing: remove "Show thread" button, handle StatusReplyMentions edge cases, fixes #793 --- app/soapbox/components/status.js | 9 +--- app/soapbox/components/status_list.js | 3 -- .../components/status_reply_mentions.js | 44 ++++++++++++++++--- .../components/scheduled_status.js | 9 +--- .../features/ui/components/pending_status.js | 9 +--- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/app/soapbox/components/status.js b/app/soapbox/components/status.js index ff9a2eb38..89f0fe934 100644 --- a/app/soapbox/components/status.js +++ b/app/soapbox/components/status.js @@ -88,7 +88,6 @@ class Status extends ImmutablePureComponent { unread: PropTypes.bool, onMoveUp: PropTypes.func, onMoveDown: PropTypes.func, - showThread: PropTypes.bool, getScrollPosition: PropTypes.func, updateScrollBottom: PropTypes.func, cacheMediaWidth: PropTypes.func, @@ -318,7 +317,7 @@ class Status extends ImmutablePureComponent { const poll = null; let statusAvatar, prepend, rebloggedByText, reblogContent; - const { intl, hidden, featured, otherAccounts, unread, showThread, group } = this.props; + const { intl, hidden, featured, otherAccounts, unread, group } = this.props; // FIXME: why does this need to reassign status and account?? let { status, account, ...other } = this.props; // eslint-disable-line prefer-const @@ -553,12 +552,6 @@ class Status extends ImmutablePureComponent { {media} {poll} - {showThread && status.get('in_reply_to_id') && status.get('in_reply_to_account_id') === status.getIn(['account', 'id']) && ( - - )} - ); } @@ -138,7 +137,6 @@ export default class StatusList extends ImmutablePureComponent { contextType={timelineId} group={group} withGroupAdmin={withGroupAdmin} - showThread /> @@ -157,7 +155,6 @@ export default class StatusList extends ImmutablePureComponent { onMoveUp={this.handleMoveUp} onMoveDown={this.handleMoveDown} contextType={timelineId} - showThread /> )); } diff --git a/app/soapbox/components/status_reply_mentions.js b/app/soapbox/components/status_reply_mentions.js index aaa934008..580880fee 100644 --- a/app/soapbox/components/status_reply_mentions.js +++ b/app/soapbox/components/status_reply_mentions.js @@ -15,12 +15,46 @@ class StatusReplyMentions extends ImmutablePureComponent { render() { const { status } = this.props; - const to = status.get('mentions', []); - - if (!status.get('in_reply_to_id') || !to || to.size === 0) { + if (!status.get('in_reply_to_id')) { return null; } + const to = status.get('mentions', []); + + // The post is a reply, but it has no mentions. + if (to.size === 0) { + // The author is replying to themself. + if (status.get('in_reply_to_account_id') === status.getIn(['account', 'id'])) { + return ( +
+ + + @{status.getIn(['account', 'username'])} + + ), + more: false, + }} + /> +
+ ); + } else { + // The reply-to is unknown. Rare, but it can happen. + return ( +
+ +
+ ); + } + } + + // The typical case with a reply-to and a list of mentions. return (
(<> - @{account.get('acct').split('@')[0]} + @{account.get('username')} {' '} )), @@ -44,4 +78,4 @@ class StatusReplyMentions extends ImmutablePureComponent { ); } -} \ No newline at end of file +} diff --git a/app/soapbox/features/scheduled_statuses/components/scheduled_status.js b/app/soapbox/features/scheduled_statuses/components/scheduled_status.js index 5226125fc..2295a0d70 100644 --- a/app/soapbox/features/scheduled_statuses/components/scheduled_status.js +++ b/app/soapbox/features/scheduled_statuses/components/scheduled_status.js @@ -1,6 +1,5 @@ import React from 'react'; import { connect } from 'react-redux'; -import { FormattedMessage } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; import StatusContent from 'soapbox/components/status_content'; import { buildStatus } from '../builder'; @@ -25,7 +24,7 @@ export default @connect(mapStateToProps) class ScheduledStatus extends ImmutablePureComponent { render() { - const { status, showThread, account, ...other } = this.props; + const { status, account, ...other } = this.props; if (!status.get('account')) return null; const statusUrl = `/scheduled_statuses/${status.get('id')}`; @@ -74,12 +73,6 @@ class ScheduledStatus extends ImmutablePureComponent { {status.get('poll') && } - {showThread && status.get('in_reply_to_id') && status.get('in_reply_to_account_id') === status.getIn(['account', 'id']) && ( - - )} -
diff --git a/app/soapbox/features/ui/components/pending_status.js b/app/soapbox/features/ui/components/pending_status.js index 638b896c9..44830822a 100644 --- a/app/soapbox/features/ui/components/pending_status.js +++ b/app/soapbox/features/ui/components/pending_status.js @@ -1,6 +1,5 @@ import React from 'react'; import { connect } from 'react-redux'; -import { FormattedMessage } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; import StatusContent from 'soapbox/components/status_content'; import { buildStatus } from '../util/pending_status_builder'; @@ -46,7 +45,7 @@ class PendingStatus extends ImmutablePureComponent { } render() { - const { status, className, showThread } = this.props; + const { status, className } = this.props; if (!status) return null; if (!status.get('account')) return null; @@ -91,12 +90,6 @@ class PendingStatus extends ImmutablePureComponent { {this.renderMedia()} {status.get('poll') && } - {showThread && status.get('in_reply_to_id') && status.get('in_reply_to_account_id') === status.getIn(['account', 'id']) && ( - - )} - {/* TODO */} {/* */}