Merge branch 'next' into 'next'
next See merge request soapbox-pub/soapbox-fe!1160
This commit is contained in:
commit
7f57f58b98
|
@ -1,3 +1,5 @@
|
||||||
|
import { getFeatures } from 'soapbox/utils/features';
|
||||||
|
|
||||||
import api from '../api';
|
import api from '../api';
|
||||||
|
|
||||||
import { importFetchedStatuses } from './importer';
|
import { importFetchedStatuses } from './importer';
|
||||||
|
@ -8,8 +10,13 @@ export const TRENDING_STATUSES_FETCH_FAIL = 'TRENDING_STATUSES_FETCH_FAIL';
|
||||||
|
|
||||||
export function fetchTrendingStatuses() {
|
export function fetchTrendingStatuses() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
|
const state = getState();
|
||||||
|
|
||||||
|
const instance = state.get('instance');
|
||||||
|
const features = getFeatures(instance);
|
||||||
|
|
||||||
dispatch({ type: TRENDING_STATUSES_FETCH_REQUEST });
|
dispatch({ type: TRENDING_STATUSES_FETCH_REQUEST });
|
||||||
return api(getState).get('/api/v1/truth/trending/truths').then(({ data: statuses }) => {
|
return api(getState).get(features.trendingTruths ? '/api/v1/truth/trending/truths' : '/api/v1/trends/statuses').then(({ data: statuses }) => {
|
||||||
dispatch(importFetchedStatuses(statuses));
|
dispatch(importFetchedStatuses(statuses));
|
||||||
dispatch({ type: TRENDING_STATUSES_FETCH_SUCCESS, statuses });
|
dispatch({ type: TRENDING_STATUSES_FETCH_SUCCESS, statuses });
|
||||||
return statuses;
|
return statuses;
|
||||||
|
|
|
@ -30,9 +30,10 @@ interface IAccount {
|
||||||
avatarSize?: number,
|
avatarSize?: number,
|
||||||
hidden?: boolean,
|
hidden?: boolean,
|
||||||
hideActions?: boolean,
|
hideActions?: boolean,
|
||||||
|
id?: string,
|
||||||
onActionClick?: (account: any) => void,
|
onActionClick?: (account: any) => void,
|
||||||
showProfileHoverCard?: boolean,
|
showProfileHoverCard?: boolean,
|
||||||
timestamp?: string,
|
timestamp?: string | Date,
|
||||||
timestampUrl?: string,
|
timestampUrl?: string,
|
||||||
withRelationship?: boolean,
|
withRelationship?: boolean,
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ const alignItemsOptions = {
|
||||||
center: 'items-center',
|
center: 'items-center',
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IStack {
|
interface IStack extends React.HTMLAttributes<HTMLDivElement > {
|
||||||
space?: SIZES,
|
space?: SIZES,
|
||||||
alignItems?: 'center',
|
alignItems?: 'center',
|
||||||
justifyContent?: 'center',
|
justifyContent?: 'center',
|
||||||
|
|
|
@ -47,7 +47,7 @@ class AwaitingApproval extends ImmutablePureComponent {
|
||||||
const showLoading = isLoading && accountIds.count() === 0;
|
const showLoading = isLoading && accountIds.count() === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='user' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='user' label={intl.formatMessage(messages.heading)}>
|
||||||
<ScrollableList
|
<ScrollableList
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
showLoading={showLoading}
|
showLoading={showLoading}
|
||||||
|
|
|
@ -84,7 +84,7 @@ class Dashboard extends ImmutablePureComponent {
|
||||||
if (!account) return null;
|
if (!account) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='tachometer-alt' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='tachometer-alt' label={intl.formatMessage(messages.heading)}>
|
||||||
<div className='dashcounters'>
|
<div className='dashcounters'>
|
||||||
{mau && <div className='dashcounter'>
|
{mau && <div className='dashcounter'>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ModerationLog extends ImmutablePureComponent {
|
||||||
const showLoading = isLoading && items.count() === 0;
|
const showLoading = isLoading && items.count() === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='balance-scale' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='balance-scale' label={intl.formatMessage(messages.heading)}>
|
||||||
<ScrollableList
|
<ScrollableList
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
showLoading={showLoading}
|
showLoading={showLoading}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Reports extends ImmutablePureComponent {
|
||||||
const showLoading = isLoading && reports.count() === 0;
|
const showLoading = isLoading && reports.count() === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='gavel' heading={intl.formatMessage(messages.heading)} menu={this.makeColumnMenu()}>
|
<Column icon='gavel' label={intl.formatMessage(messages.heading)} menu={this.makeColumnMenu()}>
|
||||||
<ScrollableList
|
<ScrollableList
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
showLoading={showLoading}
|
showLoading={showLoading}
|
||||||
|
|
|
@ -102,7 +102,7 @@ class UserIndex extends ImmutablePureComponent {
|
||||||
const showLoading = isLoading && accountIds.isEmpty();
|
const showLoading = isLoading && accountIds.isEmpty();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column heading={intl.formatMessage(messages.heading)}>
|
<Column label={intl.formatMessage(messages.heading)}>
|
||||||
<SimpleForm style={{ paddingBottom: 0 }}>
|
<SimpleForm style={{ paddingBottom: 0 }}>
|
||||||
<TextInput
|
<TextInput
|
||||||
onChange={this.handleQueryChange}
|
onChange={this.handleQueryChange}
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Aliases extends ImmutablePureComponent {
|
||||||
const emptyMessage = <FormattedMessage id='empty_column.aliases' defaultMessage="You haven't created any account alias yet." />;
|
const emptyMessage = <FormattedMessage id='empty_column.aliases' defaultMessage="You haven't created any account alias yet." />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column className='aliases-settings-panel' icon='suitcase' heading={intl.formatMessage(messages.heading)}>
|
<Column className='aliases-settings-panel' icon='suitcase' label={intl.formatMessage(messages.heading)}>
|
||||||
<ColumnSubheading text={intl.formatMessage(messages.subheading_add_new)} />
|
<ColumnSubheading text={intl.formatMessage(messages.subheading_add_new)} />
|
||||||
<Search />
|
<Search />
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Backups extends ImmutablePureComponent {
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='cloud-download' heading={intl.formatMessage(messages.heading)} menu={this.makeColumnMenu()}>
|
<Column icon='cloud-download' label={intl.formatMessage(messages.heading)} menu={this.makeColumnMenu()}>
|
||||||
<ScrollableList
|
<ScrollableList
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
showLoading={showLoading}
|
showLoading={showLoading}
|
||||||
|
|
|
@ -89,7 +89,7 @@ class Directory extends React.PureComponent {
|
||||||
const { order, local } = this.getParams(this.props, this.state);
|
const { order, local } = this.getParams(this.props, this.state);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='address-book-o' heading={intl.formatMessage(messages.title)}>
|
<Column icon='address-book-o' label={intl.formatMessage(messages.title)}>
|
||||||
<div className='directory__filter-form'>
|
<div className='directory__filter-form'>
|
||||||
<div className='directory__filter-form__column' role='group'>
|
<div className='directory__filter-form__column' role='group'>
|
||||||
<RadioButton name='order' value='active' label={intl.formatMessage(messages.recentlyActive)} checked={order === 'active'} onChange={this.handleChangeOrder} />
|
<RadioButton name='order' value='active' label={intl.formatMessage(messages.recentlyActive)} checked={order === 'active'} onChange={this.handleChangeOrder} />
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Blocks extends ImmutablePureComponent {
|
||||||
const emptyMessage = <FormattedMessage id='empty_column.domain_blocks' defaultMessage='There are no hidden domains yet.' />;
|
const emptyMessage = <FormattedMessage id='empty_column.domain_blocks' defaultMessage='There are no hidden domains yet.' />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='minus-circle' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='minus-circle' label={intl.formatMessage(messages.heading)}>
|
||||||
<ScrollableList
|
<ScrollableList
|
||||||
scrollKey='domain_blocks'
|
scrollKey='domain_blocks'
|
||||||
onLoadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
|
|
|
@ -55,7 +55,7 @@ class ExportData extends ImmutablePureComponent {
|
||||||
const { intl } = this.props;
|
const { intl } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='cloud-download-alt' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='cloud-download-alt' label={intl.formatMessage(messages.heading)}>
|
||||||
<CSVExporter action={exportFollows} messages={followMessages} />
|
<CSVExporter action={exportFollows} messages={followMessages} />
|
||||||
<CSVExporter action={exportBlocks} messages={blockMessages} />
|
<CSVExporter action={exportBlocks} messages={blockMessages} />
|
||||||
<CSVExporter action={exportMutes} messages={muteMessages} />
|
<CSVExporter action={exportMutes} messages={muteMessages} />
|
||||||
|
|
|
@ -53,7 +53,7 @@ class FederationRestrictions extends ImmutablePureComponent {
|
||||||
const emptyMessage = disclosed ? messages.emptyMessage : messages.notDisclosed;
|
const emptyMessage = disclosed ? messages.emptyMessage : messages.notDisclosed;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='gavel' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='gavel' label={intl.formatMessage(messages.heading)}>
|
||||||
<div className='explanation-box'>
|
<div className='explanation-box'>
|
||||||
<Accordion
|
<Accordion
|
||||||
headline={intl.formatMessage(messages.boxTitle)}
|
headline={intl.formatMessage(messages.boxTitle)}
|
||||||
|
|
|
@ -135,7 +135,7 @@ class Filters extends ImmutablePureComponent {
|
||||||
const emptyMessage = <FormattedMessage id='empty_column.filters' defaultMessage="You haven't created any muted words yet." />;
|
const emptyMessage = <FormattedMessage id='empty_column.filters' defaultMessage="You haven't created any muted words yet." />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column className='filter-settings-panel' icon='filter' heading={intl.formatMessage(messages.heading)}>
|
<Column className='filter-settings-panel' icon='filter' label={intl.formatMessage(messages.heading)}>
|
||||||
<ColumnSubheading text={intl.formatMessage(messages.subheading_add_new)} />
|
<ColumnSubheading text={intl.formatMessage(messages.subheading_add_new)} />
|
||||||
<SimpleForm>
|
<SimpleForm>
|
||||||
<div className='filter-settings-panel'>
|
<div className='filter-settings-panel'>
|
||||||
|
|
|
@ -57,7 +57,7 @@ class FollowRequests extends ImmutablePureComponent {
|
||||||
const emptyMessage = <FormattedMessage id='empty_column.follow_requests' defaultMessage="You don't have any follow requests yet. When you receive one, it will show up here." />;
|
const emptyMessage = <FormattedMessage id='empty_column.follow_requests' defaultMessage="You don't have any follow requests yet. When you receive one, it will show up here." />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='user-plus' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='user-plus' labellabel={intl.formatMessage(messages.heading)}>
|
||||||
<ScrollableList
|
<ScrollableList
|
||||||
scrollKey='follow_requests'
|
scrollKey='follow_requests'
|
||||||
onLoadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
|
|
|
@ -55,7 +55,7 @@ class ImportData extends ImmutablePureComponent {
|
||||||
const { intl, features } = this.props;
|
const { intl, features } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='cloud-upload-alt' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='cloud-upload-alt' label={intl.formatMessage(messages.heading)}>
|
||||||
<CSVImporter action={importFollows} messages={followMessages} />
|
<CSVImporter action={importFollows} messages={followMessages} />
|
||||||
<CSVImporter action={importBlocks} messages={blockMessages} />
|
<CSVImporter action={importBlocks} messages={blockMessages} />
|
||||||
{features.importMutes && <CSVImporter action={importMutes} messages={muteMessages} />}
|
{features.importMutes && <CSVImporter action={importMutes} messages={muteMessages} />}
|
||||||
|
|
|
@ -63,7 +63,7 @@ class Lists extends ImmutablePureComponent {
|
||||||
const emptyMessage = <FormattedMessage id='empty_column.lists' defaultMessage="You don't have any lists yet. When you create one, it will show up here." />;
|
const emptyMessage = <FormattedMessage id='empty_column.lists' defaultMessage="You don't have any lists yet. When you create one, it will show up here." />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='list-ul' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='list-ul' label={intl.formatMessage(messages.heading)}>
|
||||||
<br />
|
<br />
|
||||||
<ColumnSubheading text={intl.formatMessage(messages.add)} />
|
<ColumnSubheading text={intl.formatMessage(messages.add)} />
|
||||||
<NewListForm />
|
<NewListForm />
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Migration extends ImmutablePureComponent {
|
||||||
const { intl } = this.props;
|
const { intl } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column heading={intl.formatMessage(messages.heading)}>
|
<Column label={intl.formatMessage(messages.heading)}>
|
||||||
<SimpleForm onSubmit={this.handleSubmit}>
|
<SimpleForm onSubmit={this.handleSubmit}>
|
||||||
<fieldset disabled={this.state.isLoading}>
|
<fieldset disabled={this.state.isLoading}>
|
||||||
<FieldsGroup>
|
<FieldsGroup>
|
||||||
|
|
|
@ -52,7 +52,7 @@ class PinnedStatuses extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column heading={intl.formatMessage(messages.heading)}>
|
<Column label={intl.formatMessage(messages.heading)}>
|
||||||
<StatusList
|
<StatusList
|
||||||
statusIds={statusIds}
|
statusIds={statusIds}
|
||||||
scrollKey='pinned_statuses'
|
scrollKey='pinned_statuses'
|
||||||
|
|
|
@ -50,7 +50,7 @@ class ScheduledStatuses extends ImmutablePureComponent {
|
||||||
const emptyMessage = <FormattedMessage id='empty_column.scheduled_statuses' defaultMessage="You don't have any scheduled statuses yet. When you add one, it will show up here." />;
|
const emptyMessage = <FormattedMessage id='empty_column.scheduled_statuses' defaultMessage="You don't have any scheduled statuses yet. When you add one, it will show up here." />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='calendar' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='calendar' label={intl.formatMessage(messages.heading)}>
|
||||||
<ScrollableList
|
<ScrollableList
|
||||||
scrollKey='scheduled_statuses'
|
scrollKey='scheduled_statuses'
|
||||||
emptyMessage={emptyMessage}
|
emptyMessage={emptyMessage}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class ServerInfo extends ImmutablePureComponent {
|
||||||
const { intl, instance } = this.props;
|
const { intl, instance } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='info' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='info' label={intl.formatMessage(messages.heading)}>
|
||||||
<div className='info_column_area'>
|
<div className='info_column_area'>
|
||||||
<div className='info__brand'>
|
<div className='info__brand'>
|
||||||
<div className='brand'>
|
<div className='brand'>
|
||||||
|
|
|
@ -1,162 +0,0 @@
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
|
||||||
import { NavLink, withRouter } from 'react-router-dom';
|
|
||||||
|
|
||||||
import AttachmentThumbs from 'soapbox/components/attachment_thumbs';
|
|
||||||
import Avatar from 'soapbox/components/avatar';
|
|
||||||
import DisplayName from 'soapbox/components/display_name';
|
|
||||||
import IconButton from 'soapbox/components/icon_button';
|
|
||||||
import RelativeTimestamp from 'soapbox/components/relative_timestamp';
|
|
||||||
import { isRtl } from 'soapbox/rtl';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
cancel: { id: 'reply_indicator.cancel', defaultMessage: 'Cancel' },
|
|
||||||
});
|
|
||||||
|
|
||||||
export default @injectIntl @withRouter
|
|
||||||
class QuotedStatus extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
status: ImmutablePropTypes.record,
|
|
||||||
onCancel: PropTypes.func,
|
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
compose: PropTypes.bool,
|
|
||||||
history: PropTypes.object,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleExpandClick = e => {
|
|
||||||
const { compose, status } = this.props;
|
|
||||||
|
|
||||||
if (!compose && e.button === 0) {
|
|
||||||
if (!this.props.history) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.props.history.push(`/@${status.getIn(['account', 'acct'])}/posts/${status.get('id')}`);
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleClose = e => {
|
|
||||||
this.props.onCancel();
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
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: `@${status.getIn(['account', 'username'])}`,
|
|
||||||
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 => `@${account.get('username')} `),
|
|
||||||
more: to.size > 2 && <FormattedMessage id='reply_mentions.more' defaultMessage='and {count} more' values={{ count: to.size - 2 }} />,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { status, onCancel, intl, compose } = this.props;
|
|
||||||
|
|
||||||
if (!status) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = { __html: status.get('contentHtml') };
|
|
||||||
const style = {
|
|
||||||
direction: isRtl(status.get('search_index')) ? 'rtl' : 'ltr',
|
|
||||||
};
|
|
||||||
|
|
||||||
const displayName = (<>
|
|
||||||
<div className='quoted-status__display-avatar'><Avatar account={status.get('account')} size={24} /></div>
|
|
||||||
<DisplayName account={status.get('account')} />
|
|
||||||
</>);
|
|
||||||
|
|
||||||
const quotedStatus = (
|
|
||||||
<div className='quoted-status' onClick={this.handleExpandClick} role='presentation'>
|
|
||||||
<div className='quoted-status__info'>
|
|
||||||
{onCancel
|
|
||||||
? (
|
|
||||||
<div className='reply-indicator__cancel'>
|
|
||||||
<IconButton title={intl.formatMessage(messages.cancel)} src={require('@tabler/icons/icons/x.svg')} onClick={this.handleClose} inverted />
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className='quoted-status__relative-time'>
|
|
||||||
<RelativeTimestamp timestamp={status.get('created_at')} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{compose ? (
|
|
||||||
<div className='quoted-status__display-name'>
|
|
||||||
{displayName}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<NavLink to={`/@${status.getIn(['account', 'acct'])}`} className='quoted-status__display-name'>
|
|
||||||
{displayName}
|
|
||||||
</NavLink>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{this.renderReplyMentions()}
|
|
||||||
|
|
||||||
<div className='quoted-status__content' style={style} dangerouslySetInnerHTML={content} />
|
|
||||||
|
|
||||||
{status.get('media_attachments').size > 0 && (
|
|
||||||
<AttachmentThumbs
|
|
||||||
compact
|
|
||||||
media={status.get('media_attachments')}
|
|
||||||
sensitive={status.get('sensitive')}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (compose) {
|
|
||||||
return (
|
|
||||||
<div className='compose-form__quoted-status-wrapper'>
|
|
||||||
{quotedStatus}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return quotedStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import { History } from 'history';
|
||||||
|
import React from 'react';
|
||||||
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
import { defineMessages, injectIntl, FormattedMessage, IntlShape } from 'react-intl';
|
||||||
|
import { withRouter } from 'react-router-dom';
|
||||||
|
|
||||||
|
import AttachmentThumbs from 'soapbox/components/attachment_thumbs';
|
||||||
|
import { Stack, Text } from 'soapbox/components/ui';
|
||||||
|
import AccountContainer from 'soapbox/containers/account_container';
|
||||||
|
import { Account as AccountEntity, Status as StatusEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
cancel: { id: 'reply_indicator.cancel', defaultMessage: 'Cancel' },
|
||||||
|
});
|
||||||
|
|
||||||
|
interface IQuotedStatus {
|
||||||
|
status?: StatusEntity,
|
||||||
|
onCancel?: Function,
|
||||||
|
intl: IntlShape,
|
||||||
|
compose?: boolean,
|
||||||
|
history: History,
|
||||||
|
}
|
||||||
|
|
||||||
|
class QuotedStatus extends ImmutablePureComponent<IQuotedStatus> {
|
||||||
|
|
||||||
|
handleExpandClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
const { compose, status } = this.props;
|
||||||
|
|
||||||
|
if (!status) return;
|
||||||
|
|
||||||
|
const account = status.account as AccountEntity;
|
||||||
|
|
||||||
|
if (!compose && e.button === 0) {
|
||||||
|
if (!this.props.history) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.props.history.push(`/@${account.acct}/posts/${status.id}`);
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleClose = () => {
|
||||||
|
if (this.props.onCancel) {
|
||||||
|
this.props.onCancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderReplyMentions = () => {
|
||||||
|
const { status } = this.props;
|
||||||
|
|
||||||
|
if (!status?.in_reply_to_id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const account = status.account as AccountEntity;
|
||||||
|
|
||||||
|
const to = status.mentions || [];
|
||||||
|
|
||||||
|
if (to.size === 0) {
|
||||||
|
if (status.in_reply_to_account_id === account.id) {
|
||||||
|
return (
|
||||||
|
<div className='reply-mentions'>
|
||||||
|
<FormattedMessage
|
||||||
|
id='reply_mentions.reply'
|
||||||
|
defaultMessage='Replying to {accounts}{more}'
|
||||||
|
values={{
|
||||||
|
accounts: `@${account.username}`,
|
||||||
|
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 => `@${account.username} `),
|
||||||
|
more: to.size > 2 && <FormattedMessage id='reply_mentions.more' defaultMessage='and {count} more' values={{ count: to.size - 2 }} />,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { status, onCancel, intl, compose } = this.props;
|
||||||
|
|
||||||
|
if (!status) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const account = status.account as AccountEntity;
|
||||||
|
|
||||||
|
let actions = {};
|
||||||
|
if (onCancel) {
|
||||||
|
actions = {
|
||||||
|
onActionClick: this.handleClose,
|
||||||
|
actionIcon: require('@tabler/icons/icons/x.svg'),
|
||||||
|
actionAlignment: 'top',
|
||||||
|
actionTitle: intl.formatMessage(messages.cancel),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const quotedStatus = (
|
||||||
|
<Stack
|
||||||
|
space={2}
|
||||||
|
className={classNames('mt-3 p-4 rounded-lg border border-solid border-gray-100 dark:border-slate-700 cursor-pointer', {
|
||||||
|
'hover:bg-gray-100 dark:hover:bg-slate-700': !compose,
|
||||||
|
})}
|
||||||
|
onClick={this.handleExpandClick}
|
||||||
|
>
|
||||||
|
<AccountContainer
|
||||||
|
{...actions}
|
||||||
|
id={account.id}
|
||||||
|
timestamp={status.created_at}
|
||||||
|
showProfileHoverCard={!compose}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{this.renderReplyMentions()}
|
||||||
|
|
||||||
|
<Text
|
||||||
|
size='sm'
|
||||||
|
dangerouslySetInnerHTML={{ __html: status.contentHtml }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{status.media_attachments.size > 0 && (
|
||||||
|
<AttachmentThumbs
|
||||||
|
compact
|
||||||
|
media={status.media_attachments}
|
||||||
|
sensitive={status.sensitive}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
|
||||||
|
return quotedStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withRouter(injectIntl(QuotedStatus) as any);
|
|
@ -123,6 +123,8 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
v.software === MASTODON && gte(v.compatVersion, '3.2.0'),
|
v.software === MASTODON && gte(v.compatVersion, '3.2.0'),
|
||||||
v.software === PLEROMA && gte(v.version, '2.4.50'),
|
v.software === PLEROMA && gte(v.version, '2.4.50'),
|
||||||
]),
|
]),
|
||||||
|
trendingTruths: v.software === TRUTHSOCIAL,
|
||||||
|
trendingStatuses: v.software === MASTODON && gte(v.compatVersion, '3.5.0'),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue