sforkowany z mirror/soapbox
Merge branch 'revert-db7c7b36' into 'develop'
Revert "Merge branch 'pending-replying-to' into 'develop'" See merge request soapbox-pub/soapbox-fe!989profile-avatar-switcher
commit
5381b27c7e
|
@ -1,7 +1,6 @@
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import { FormattedMessage, injectIntl } from 'react-intl';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { Link, NavLink } from 'react-router-dom';
|
import { Link, NavLink } from 'react-router-dom';
|
||||||
|
|
||||||
|
@ -30,7 +29,6 @@ const mapStateToProps = (state, props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default @connect(mapStateToProps)
|
export default @connect(mapStateToProps)
|
||||||
@injectIntl
|
|
||||||
class PendingStatus extends ImmutablePureComponent {
|
class PendingStatus extends ImmutablePureComponent {
|
||||||
|
|
||||||
renderMedia = () => {
|
renderMedia = () => {
|
||||||
|
@ -49,56 +47,6 @@ 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 (
|
|
||||||
<div className='reply-mentions'>
|
|
||||||
<FormattedMessage
|
|
||||||
id='reply_mentions.reply'
|
|
||||||
defaultMessage='Replying to {accounts}{more}'
|
|
||||||
values={{
|
|
||||||
accounts: <span className='reply-mentions__account'>@{status.getIn(['account', 'username'])}</span>,
|
|
||||||
more: false,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<div className='reply-mentions'>
|
|
||||||
<FormattedMessage id='reply_mentions.reply_empty' defaultMessage='Replying to post' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='reply-mentions'>
|
|
||||||
<FormattedMessage
|
|
||||||
id='reply_mentions.reply'
|
|
||||||
defaultMessage='Replying to {accounts}{more}'
|
|
||||||
values={{
|
|
||||||
accounts: to.slice(0, 2).map(account => (<>
|
|
||||||
<span key={account.username} className='reply-mentions__account'>@{account.username}</span>
|
|
||||||
{' '}
|
|
||||||
</>)),
|
|
||||||
more: to.size > 2 && <FormattedMessage id='reply_mentions.more' defaultMessage='and {count} more' values={{ count: to.size - 2 }} />,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { status, className } = this.props;
|
const { status, className } = this.props;
|
||||||
if (!status) return null;
|
if (!status) return null;
|
||||||
|
@ -136,8 +84,6 @@ class PendingStatus extends ImmutablePureComponent {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{this.renderReplyMentions()}
|
|
||||||
|
|
||||||
<StatusContent
|
<StatusContent
|
||||||
status={status}
|
status={status}
|
||||||
expanded
|
expanded
|
||||||
|
|
|
@ -1,24 +1,14 @@
|
||||||
import { fromJS } from 'immutable';
|
import { fromJS } from 'immutable';
|
||||||
import { OrderedSet as ImmutableOrderedSet } from 'immutable';
|
|
||||||
|
|
||||||
import { normalizeStatus } from 'soapbox/actions/importer/normalizer';
|
import { normalizeStatus } from 'soapbox/actions/importer/normalizer';
|
||||||
import { makeGetAccount, makeGetStatus } from 'soapbox/selectors';
|
import { makeGetAccount } from 'soapbox/selectors';
|
||||||
|
|
||||||
export const buildStatus = (state, pendingStatus, idempotencyKey) => {
|
export const buildStatus = (state, pendingStatus, idempotencyKey) => {
|
||||||
const getAccount = makeGetAccount();
|
const getAccount = makeGetAccount();
|
||||||
const getStatus = makeGetStatus();
|
|
||||||
|
|
||||||
const me = state.get('me');
|
const me = state.get('me');
|
||||||
const account = getAccount(state, 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({
|
const status = normalizeStatus({
|
||||||
account,
|
account,
|
||||||
application: null,
|
application: null,
|
||||||
|
@ -34,13 +24,7 @@ export const buildStatus = (state, pendingStatus, idempotencyKey) => {
|
||||||
in_reply_to_id: pendingStatus.get('in_reply_to_id'),
|
in_reply_to_id: pendingStatus.get('in_reply_to_id'),
|
||||||
language: null,
|
language: null,
|
||||||
media_attachments: pendingStatus.get('media_ids').map(id => ({ id })),
|
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,
|
muted: false,
|
||||||
pinned: false,
|
pinned: false,
|
||||||
poll: pendingStatus.get('poll', null),
|
poll: pendingStatus.get('poll', null),
|
||||||
|
|
Ładowanie…
Reference in New Issue