From 5afd1ce4b3527ff2b0aedd5ff1799e90f604a6a2 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 21 Feb 2022 03:56:31 -0500 Subject: [PATCH] Fix PendingStatus --- .../features/scheduled_statuses/builder.js | 3 +- .../components/scheduled_status.js | 3 + .../features/ui/components/pending_status.js | 55 +------------------ .../ui/util/pending_status_builder.js | 8 ++- app/soapbox/reducers/statuses.js | 2 +- 5 files changed, 14 insertions(+), 57 deletions(-) diff --git a/app/soapbox/features/scheduled_statuses/builder.js b/app/soapbox/features/scheduled_statuses/builder.js index d9ba1fdf9..2849f5539 100644 --- a/app/soapbox/features/scheduled_statuses/builder.js +++ b/app/soapbox/features/scheduled_statuses/builder.js @@ -1,6 +1,7 @@ import { fromJS } from 'immutable'; import { normalizeStatus } from 'soapbox/normalizers/status'; +import { calculateStatus } from 'soapbox/reducers/statuses'; import { makeGetAccount } from 'soapbox/selectors'; export const buildStatus = (state, scheduledStatus) => { @@ -42,5 +43,5 @@ export const buildStatus = (state, scheduledStatus) => { visibility: params.get('visibility'), }; - return normalizeStatus(fromJS(status)); + return calculateStatus(normalizeStatus(fromJS(status))); }; diff --git a/app/soapbox/features/scheduled_statuses/components/scheduled_status.js b/app/soapbox/features/scheduled_statuses/components/scheduled_status.js index b47e2b6d0..c79de8af1 100644 --- a/app/soapbox/features/scheduled_statuses/components/scheduled_status.js +++ b/app/soapbox/features/scheduled_statuses/components/scheduled_status.js @@ -9,6 +9,7 @@ import Avatar from 'soapbox/components/avatar'; import DisplayName from 'soapbox/components/display_name'; import RelativeTimestamp from 'soapbox/components/relative_timestamp'; import StatusContent from 'soapbox/components/status_content'; +import StatusReplyMentions from 'soapbox/components/status_reply_mentions'; import PollPreview from 'soapbox/features/ui/components/poll_preview'; import { getDomain } from 'soapbox/utils/accounts'; @@ -63,6 +64,8 @@ class ScheduledStatus extends ImmutablePureComponent { + + { - 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; @@ -137,7 +88,7 @@ class PendingStatus extends ImmutablePureComponent { - {this.renderReplyMentions()} + { @@ -21,8 +22,9 @@ export const buildStatus = (state, pendingStatus, idempotencyKey) => { mentions = pendingStatus.get('to', []); } - mentions = mentions.map(mention => ({ + mentions = mentions.toList().map(mention => ImmutableMap({ username: mention.split('@')[0], + acct: mention, })); } @@ -59,5 +61,5 @@ export const buildStatus = (state, pendingStatus, idempotencyKey) => { visibility: pendingStatus.get('visibility', 'public'), }; - return normalizeStatus(fromJS(status)); + return calculateStatus(normalizeStatus(fromJS(status))); }; diff --git a/app/soapbox/reducers/statuses.js b/app/soapbox/reducers/statuses.js index e1af8cf30..ab822b59f 100644 --- a/app/soapbox/reducers/statuses.js +++ b/app/soapbox/reducers/statuses.js @@ -48,7 +48,7 @@ const minifyStatus = status => { // Only calculate these values when status first encountered // Otherwise keep the ones already in the reducer -const calculateStatus = (status, oldStatus, expandSpoilers = false) => { +export const calculateStatus = (status, oldStatus, expandSpoilers = false) => { if (oldStatus) { return status.merge({ search_index: oldStatus.get('search_index'),