Merge branch 'restore-account-endorsements' into 'develop'

Restore featured accounts

See merge request soapbox-pub/soapbox-fe!1670
This commit is contained in:
marcin mikołajczak
2022-07-22 13:37:59 +00:00
6 changed files with 39 additions and 13 deletions

View File

@@ -257,7 +257,14 @@ class Header extends ImmutablePureComponent {
});
}
// menu.push({ text: intl.formatMessage(account.relationship?.endorsed ? messages.unendorse : messages.endorse), action: this.props.onEndorseToggle });
if (features.accountEndorsements) {
menu.push({
text: intl.formatMessage(account.relationship?.endorsed ? messages.unendorse : messages.endorse),
action: this.props.onEndorseToggle,
icon: require('@tabler/icons/user-check.svg'),
});
}
menu.push(null);
} else if (features.lists && features.unrestrictedLists) {
menu.push({

View File

@@ -58,6 +58,8 @@ const messages = defineMessages({
userSuggested: { id: 'admin.users.user_suggested_message', defaultMessage: '@{acct} was suggested' },
userUnsuggested: { id: 'admin.users.user_unsuggested_message', defaultMessage: '@{acct} was unsuggested' },
removeFromFollowersConfirm: { id: 'confirmations.remove_from_followers.confirm', defaultMessage: 'Remove' },
userEndorsed: { id: 'account.endorse.success', defaultMessage: 'You are now featuring @{acct} on your profile' },
userUnendorsed: { id: 'account.unendorse.success', defaultMessage: 'You are no longer featuring @{acct}' },
});
const makeMapStateToProps = () => {
@@ -144,9 +146,13 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onEndorseToggle(account) {
if (account.relationship?.endorsed) {
dispatch(unpinAccount(account.get('id')));
dispatch(unpinAccount(account.get('id')))
.then(() => dispatch(snackbar.success(intl.formatMessage(messages.userUnendorsed, { acct: account.acct }))))
.catch(() => {});
} else {
dispatch(pinAccount(account.get('id')));
dispatch(pinAccount(account.get('id')))
.then(() => dispatch(snackbar.success(intl.formatMessage(messages.userEndorsed, { acct: account.acct }))))
.catch(() => {});
}
},

View File

@@ -5,6 +5,8 @@ import { FormattedMessage } from 'react-intl';
import { fetchPinnedAccounts } from 'soapbox/actions/accounts';
import { Widget } from 'soapbox/components/ui';
import AccountContainer from 'soapbox/containers/account_container';
import BundleContainer from 'soapbox/features/ui/containers/bundle_container';
import { WhoToFollowPanel } from 'soapbox/features/ui/util/async-components';
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
import type { Account } from 'soapbox/types/entities';
@@ -23,7 +25,11 @@ const PinnedAccountsPanel: React.FC<IPinnedAccountsPanel> = ({ account, limit })
}, []);
if (pinned.isEmpty()) {
return null;
return (
<BundleContainer fetchComponent={WhoToFollowPanel}>
{Component => <Component limit={limit} />}
</BundleContainer>
);
}
return (
@@ -32,7 +38,7 @@ const PinnedAccountsPanel: React.FC<IPinnedAccountsPanel> = ({ account, limit })
id='pinned_accounts.title'
defaultMessage='{name}s choices'
values={{
name: <span className='display-name__html' dangerouslySetInnerHTML={{ __html: account.display_name_html }} />,
name: <span dangerouslySetInnerHTML={{ __html: account.display_name_html }} />,
}}
/>}
>

View File

@@ -17,8 +17,8 @@ const messages = defineMessages({
unsubscribe: { id: 'account.unsubscribe', defaultMessage: 'Unsubscribe to notifications from @{name}' },
subscribeSuccess: { id: 'account.subscribe.success', defaultMessage: 'You have subscribed to this account.' },
unsubscribeSuccess: { id: 'account.unsubscribe.success', defaultMessage: 'You have unsubscribed from this account.' },
subscribeFailure: { id: 'account.subscribe.failure', defaultMessage: 'An error occurred trying to subscribed to this account.' },
unsubscribeFailure: { id: 'account.unsubscribe.failure', defaultMessage: 'An error occurred trying to unsubscribed to this account.' },
subscribeFailure: { id: 'account.subscribe.failure', defaultMessage: 'An error occurred trying to subscribe to this account.' },
unsubscribeFailure: { id: 'account.unsubscribe.failure', defaultMessage: 'An error occurred trying to unsubscribe to this account.' },
});
interface ISubscriptionButton {