From c89fcb80d24ed35a4a8e487b830da3a6e27554cc Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 14 Jan 2022 21:35:28 +0000 Subject: [PATCH 1/2] Revert "Merge branch 'revert-db7c7b36' into 'develop'" This reverts merge request !989 --- .../features/ui/components/pending_status.js | 54 +++++++++++++++++++ .../ui/util/pending_status_builder.js | 20 ++++++- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/app/soapbox/features/ui/components/pending_status.js b/app/soapbox/features/ui/components/pending_status.js index 847869457..f21bfe010 100644 --- a/app/soapbox/features/ui/components/pending_status.js +++ b/app/soapbox/features/ui/components/pending_status.js @@ -1,6 +1,7 @@ import classNames from 'classnames'; import React from 'react'; import ImmutablePureComponent from 'react-immutable-pure-component'; +import { FormattedMessage, injectIntl } from 'react-intl'; import { connect } from 'react-redux'; import { Link, NavLink } from 'react-router-dom'; @@ -29,6 +30,7 @@ const mapStateToProps = (state, props) => { }; export default @connect(mapStateToProps) +@injectIntl class PendingStatus extends ImmutablePureComponent { renderMedia = () => { @@ -47,6 +49,56 @@ class PendingStatus extends ImmutablePureComponent { } } + renderReplyMentions = () => { + const { status } = this.props; + + if (!status.get('in_reply_to_id')) { + return null; + } + + const to = status.get('mentions', []); + + if (to.size === 0) { + if (status.get('in_reply_to_account_id') === status.getIn(['account', 'id'])) { + return ( +
+ @{status.getIn(['account', 'username'])}, + more: false, + }} + /> +
+ ); + } else { + return ( +
+ +
+ ); + } + } + + + return ( +
+ (<> + @{account.username} + {' '} + )), + more: to.size > 2 && , + }} + /> +
+ ); + } + render() { const { status, className } = this.props; if (!status) return null; @@ -84,6 +136,8 @@ class PendingStatus extends ImmutablePureComponent { + {this.renderReplyMentions()} + { const getAccount = makeGetAccount(); + const getStatus = makeGetStatus(); const me = state.get('me'); const account = getAccount(state, me); + let replyToSelf = false; + if (pendingStatus.get('in_reply_to_id')) { + const inReplyTo = getStatus(state, { id: pendingStatus.get('in_reply_to_id') }); + + if (inReplyTo.getIn(['account', 'id']) === me) + replyToSelf = true; + } + const status = normalizeStatus({ account, application: null, @@ -24,7 +34,13 @@ export const buildStatus = (state, pendingStatus, idempotencyKey) => { in_reply_to_id: pendingStatus.get('in_reply_to_id'), language: null, media_attachments: pendingStatus.get('media_ids').map(id => ({ id })), - mentions: [], + mentions: ( + replyToSelf + ? ImmutableOrderedSet([account.get('acct')]).union(pendingStatus.get('to')) + : pendingStatus.get('to') + ).map(mention => ({ + username: mention.split('@')[0], + })), muted: false, pinned: false, poll: pendingStatus.get('poll', null), From 0647394f5f4175687512a78d9f241ee65aac3bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 15 Jan 2022 14:29:32 +0100 Subject: [PATCH 2/2] Fix crash in pending_status_builder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../ui/util/pending_status_builder.js | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/soapbox/features/ui/util/pending_status_builder.js b/app/soapbox/features/ui/util/pending_status_builder.js index ea3cb92ca..912e19015 100644 --- a/app/soapbox/features/ui/util/pending_status_builder.js +++ b/app/soapbox/features/ui/util/pending_status_builder.js @@ -11,12 +11,19 @@ export const buildStatus = (state, pendingStatus, idempotencyKey) => { const me = state.get('me'); const account = getAccount(state, me); - let replyToSelf = false; + let mentions; if (pendingStatus.get('in_reply_to_id')) { const inReplyTo = getStatus(state, { id: pendingStatus.get('in_reply_to_id') }); - if (inReplyTo.getIn(['account', 'id']) === me) - replyToSelf = true; + if (inReplyTo.getIn(['account', 'id']) === me) { + mentions = ImmutableOrderedSet([account.get('acct')]).union(pendingStatus.get('to', [])); + } else { + mentions = pendingStatus.get('to', []); + } + + mentions = mentions.map(mention => ({ + username: mention.split('@')[0], + })); } const status = normalizeStatus({ @@ -34,13 +41,7 @@ export const buildStatus = (state, pendingStatus, idempotencyKey) => { in_reply_to_id: pendingStatus.get('in_reply_to_id'), language: null, media_attachments: pendingStatus.get('media_ids').map(id => ({ id })), - mentions: ( - replyToSelf - ? ImmutableOrderedSet([account.get('acct')]).union(pendingStatus.get('to')) - : pendingStatus.get('to') - ).map(mention => ({ - username: mention.split('@')[0], - })), + mentions, muted: false, pinned: false, poll: pendingStatus.get('poll', null),