From 6023f69b2e713a58bdf5f174ae01159e0157bfec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 29 Mar 2022 16:26:02 +0200 Subject: [PATCH 1/3] remove duplicate column headings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/features/admin/awaiting_approval.js | 2 +- app/soapbox/features/admin/index.js | 2 +- app/soapbox/features/admin/moderation_log.js | 2 +- app/soapbox/features/admin/reports.js | 2 +- app/soapbox/features/admin/user_index.js | 2 +- app/soapbox/features/aliases/index.js | 2 +- app/soapbox/features/backups/index.js | 2 +- app/soapbox/features/directory/index.js | 2 +- app/soapbox/features/domain_blocks/index.js | 2 +- app/soapbox/features/export_data/index.js | 2 +- app/soapbox/features/federation_restrictions/index.js | 2 +- app/soapbox/features/filters/index.js | 2 +- app/soapbox/features/follow_requests/index.js | 2 +- app/soapbox/features/import_data/index.js | 2 +- app/soapbox/features/lists/index.js | 2 +- app/soapbox/features/migration/index.js | 2 +- app/soapbox/features/pinned_statuses/index.js | 2 +- app/soapbox/features/scheduled_statuses/index.js | 2 +- app/soapbox/features/server_info/index.js | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/soapbox/features/admin/awaiting_approval.js b/app/soapbox/features/admin/awaiting_approval.js index bdd909b3b..fa0e538ff 100644 --- a/app/soapbox/features/admin/awaiting_approval.js +++ b/app/soapbox/features/admin/awaiting_approval.js @@ -47,7 +47,7 @@ class AwaitingApproval extends ImmutablePureComponent { const showLoading = isLoading && accountIds.count() === 0; return ( - + +
{mau &&
diff --git a/app/soapbox/features/admin/moderation_log.js b/app/soapbox/features/admin/moderation_log.js index 12c3cee82..a4f50ddbb 100644 --- a/app/soapbox/features/admin/moderation_log.js +++ b/app/soapbox/features/admin/moderation_log.js @@ -62,7 +62,7 @@ class ModerationLog extends ImmutablePureComponent { const showLoading = isLoading && items.count() === 0; return ( - + + + ; return ( - + { diff --git a/app/soapbox/features/backups/index.js b/app/soapbox/features/backups/index.js index 2bd342222..ac0fb29fd 100644 --- a/app/soapbox/features/backups/index.js +++ b/app/soapbox/features/backups/index.js @@ -70,7 +70,7 @@ class Backups extends ImmutablePureComponent { ); return ( - + +
diff --git a/app/soapbox/features/domain_blocks/index.js b/app/soapbox/features/domain_blocks/index.js index c4a5777a2..3ab084564 100644 --- a/app/soapbox/features/domain_blocks/index.js +++ b/app/soapbox/features/domain_blocks/index.js @@ -57,7 +57,7 @@ class Blocks extends ImmutablePureComponent { const emptyMessage = ; return ( - + + diff --git a/app/soapbox/features/federation_restrictions/index.js b/app/soapbox/features/federation_restrictions/index.js index dc83d0e27..bb5ccdab2 100644 --- a/app/soapbox/features/federation_restrictions/index.js +++ b/app/soapbox/features/federation_restrictions/index.js @@ -53,7 +53,7 @@ class FederationRestrictions extends ImmutablePureComponent { const emptyMessage = disclosed ? messages.emptyMessage : messages.notDisclosed; return ( - +
; return ( - +
diff --git a/app/soapbox/features/follow_requests/index.js b/app/soapbox/features/follow_requests/index.js index 1bf817597..3c3f8f75e 100644 --- a/app/soapbox/features/follow_requests/index.js +++ b/app/soapbox/features/follow_requests/index.js @@ -57,7 +57,7 @@ class FollowRequests extends ImmutablePureComponent { const emptyMessage = ; return ( - + + {features.importMutes && } diff --git a/app/soapbox/features/lists/index.js b/app/soapbox/features/lists/index.js index eddfbcc0f..85b444301 100644 --- a/app/soapbox/features/lists/index.js +++ b/app/soapbox/features/lists/index.js @@ -63,7 +63,7 @@ class Lists extends ImmutablePureComponent { const emptyMessage = ; return ( - +
diff --git a/app/soapbox/features/migration/index.js b/app/soapbox/features/migration/index.js index a999ca030..1903682b9 100644 --- a/app/soapbox/features/migration/index.js +++ b/app/soapbox/features/migration/index.js @@ -62,7 +62,7 @@ class Migration extends ImmutablePureComponent { const { intl } = this.props; return ( - +
diff --git a/app/soapbox/features/pinned_statuses/index.js b/app/soapbox/features/pinned_statuses/index.js index 04a46d8e1..a045641a4 100644 --- a/app/soapbox/features/pinned_statuses/index.js +++ b/app/soapbox/features/pinned_statuses/index.js @@ -52,7 +52,7 @@ class PinnedStatuses extends ImmutablePureComponent { } return ( - + ; return ( - + +
From 6d4d96528c60ee56a6cea8a158b2c6ad0d0ef4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 29 Mar 2022 20:12:49 +0200 Subject: [PATCH 2/3] quote posts? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/components/account.tsx | 3 +- app/soapbox/components/ui/stack/stack.tsx | 2 +- .../status/components/quoted_status.js | 162 ------------------ .../status/components/quoted_status.tsx | 155 +++++++++++++++++ 4 files changed, 158 insertions(+), 164 deletions(-) delete mode 100644 app/soapbox/features/status/components/quoted_status.js create mode 100644 app/soapbox/features/status/components/quoted_status.tsx diff --git a/app/soapbox/components/account.tsx b/app/soapbox/components/account.tsx index cd8ee546e..21178d5e4 100644 --- a/app/soapbox/components/account.tsx +++ b/app/soapbox/components/account.tsx @@ -30,9 +30,10 @@ interface IAccount { avatarSize?: number, hidden?: boolean, hideActions?: boolean, + id?: string, onActionClick?: (account: any) => void, showProfileHoverCard?: boolean, - timestamp?: string, + timestamp?: string | Date, timestampUrl?: string, withRelationship?: boolean, } diff --git a/app/soapbox/components/ui/stack/stack.tsx b/app/soapbox/components/ui/stack/stack.tsx index 46e29d0f6..1441ae17e 100644 --- a/app/soapbox/components/ui/stack/stack.tsx +++ b/app/soapbox/components/ui/stack/stack.tsx @@ -21,7 +21,7 @@ const alignItemsOptions = { center: 'items-center', }; -interface IStack { +interface IStack extends React.HTMLAttributes { space?: SIZES, alignItems?: 'center', justifyContent?: 'center', diff --git a/app/soapbox/features/status/components/quoted_status.js b/app/soapbox/features/status/components/quoted_status.js deleted file mode 100644 index c31415a02..000000000 --- a/app/soapbox/features/status/components/quoted_status.js +++ /dev/null @@ -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 ( -
- -
- ); - } else { - return ( -
- -
- ); - } - } - - return ( -
- `@${account.get('username')} `), - more: to.size > 2 && , - }} - /> -
- ); - } - - 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 = (<> -
- - ); - - const quotedStatus = ( -
-
- {onCancel - ? ( -
- -
- ) : ( -
- -
- )} - {compose ? ( -
- {displayName} -
- ) : ( - - {displayName} - - )} -
- - {this.renderReplyMentions()} - -
- - {status.get('media_attachments').size > 0 && ( - - )} -
- ); - - if (compose) { - return ( -
- {quotedStatus} -
- ); - } - - return quotedStatus; - } - -} diff --git a/app/soapbox/features/status/components/quoted_status.tsx b/app/soapbox/features/status/components/quoted_status.tsx new file mode 100644 index 000000000..25c8e850e --- /dev/null +++ b/app/soapbox/features/status/components/quoted_status.tsx @@ -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 { + + handleExpandClick = (e: React.MouseEvent) => { + 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 ( +
+ +
+ ); + } else { + return ( +
+ +
+ ); + } + } + + return ( +
+ `@${account.username} `), + more: to.size > 2 && , + }} + /> +
+ ); + } + + 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 = ( + + + + {this.renderReplyMentions()} + + + + {status.media_attachments.size > 0 && ( + + )} + + ); + + return quotedStatus; + } + +} + +export default withRouter(injectIntl(QuotedStatus) as any); \ No newline at end of file From 36c0fb5882d0f6a64fb8a57ae7625aeced96d2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 29 Mar 2022 21:15:06 +0200 Subject: [PATCH 3/3] Support trending statuses from Mastodon 3.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/actions/trending_statuses.js | 9 ++++++++- app/soapbox/utils/features.ts | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/soapbox/actions/trending_statuses.js b/app/soapbox/actions/trending_statuses.js index b01a3da01..23cf56977 100644 --- a/app/soapbox/actions/trending_statuses.js +++ b/app/soapbox/actions/trending_statuses.js @@ -1,3 +1,5 @@ +import { getFeatures } from 'soapbox/utils/features'; + import api from '../api'; import { importFetchedStatuses } from './importer'; @@ -8,8 +10,13 @@ export const TRENDING_STATUSES_FETCH_FAIL = 'TRENDING_STATUSES_FETCH_FAIL'; export function fetchTrendingStatuses() { return (dispatch, getState) => { + const state = getState(); + + const instance = state.get('instance'); + const features = getFeatures(instance); + 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({ type: TRENDING_STATUSES_FETCH_SUCCESS, statuses }); return statuses; diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index 1bb256172..7e5ca16ed 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -123,6 +123,8 @@ const getInstanceFeatures = (instance: Instance) => { v.software === MASTODON && gte(v.compatVersion, '3.2.0'), v.software === PLEROMA && gte(v.version, '2.4.50'), ]), + trendingTruths: v.software === TRUTHSOCIAL, + trendingStatuses: v.software === MASTODON && gte(v.compatVersion, '3.5.0'), }; };