kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Support account subscriptions on Mastodon
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>improve-ci
rodzic
ab886e647c
commit
fc3b9d62a6
|
@ -203,7 +203,7 @@ export function fetchAccountFail(id, error) {
|
|||
};
|
||||
}
|
||||
|
||||
export function followAccount(id, reblogs = true) {
|
||||
export function followAccount(id, options = { reblogs: true }) {
|
||||
return (dispatch, getState) => {
|
||||
if (!isLoggedIn(getState)) return;
|
||||
|
||||
|
@ -212,7 +212,7 @@ export function followAccount(id, reblogs = true) {
|
|||
|
||||
dispatch(followAccountRequest(id, locked));
|
||||
|
||||
api(getState).post(`/api/v1/accounts/${id}/follow`, { reblogs }).then(response => {
|
||||
api(getState).post(`/api/v1/accounts/${id}/follow`, options).then(response => {
|
||||
dispatch(followAccountSuccess(response.data, alreadyFollowing));
|
||||
}).catch(error => {
|
||||
dispatch(followAccountFail(error, locked));
|
||||
|
|
|
@ -256,7 +256,21 @@ class Header extends ImmutablePureComponent {
|
|||
});
|
||||
}
|
||||
|
||||
if (features.accountSubscriptions) {
|
||||
if (features.accountNotifies) {
|
||||
if (account.getIn(['relationship', 'notifying'])) {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.unsubscribe, { name: account.get('username') }),
|
||||
action: this.props.onNotifyToggle,
|
||||
icon: require('@tabler/icons/icons/bell.svg'),
|
||||
});
|
||||
} else {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.subscribe, { name: account.get('username') }),
|
||||
action: this.props.onNotifyToggle,
|
||||
icon: require('@tabler/icons/icons/bell-off.svg'),
|
||||
});
|
||||
}
|
||||
} else if (features.accountSubscriptions) {
|
||||
if (account.getIn(['relationship', 'subscribing'])) {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.unsubscribe, { name: account.get('username') }),
|
||||
|
@ -550,8 +564,8 @@ class Header extends ImmutablePureComponent {
|
|||
<StillImage src={account.get('header')} alt='' className='parallax' />
|
||||
</a>}
|
||||
|
||||
{features.accountSubscriptions && <div className='account__header__subscribe'>
|
||||
<SubscriptionButton account={account} />
|
||||
{(features.accountNotifies || features.accountSubscriptions) && <div className='account__header__subscribe'>
|
||||
<SubscriptionButton account={account} features={features} />
|
||||
</div>}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -57,6 +57,10 @@ export default class Header extends ImmutablePureComponent {
|
|||
this.props.onSubscriptionToggle(this.props.account);
|
||||
}
|
||||
|
||||
handleNotifyToggle = () => {
|
||||
this.props.onNotifyToggle(this.props.account);
|
||||
}
|
||||
|
||||
handleMute = () => {
|
||||
this.props.onMute(this.props.account);
|
||||
}
|
||||
|
@ -143,6 +147,7 @@ export default class Header extends ImmutablePureComponent {
|
|||
onChat={this.handleChat}
|
||||
onReblogToggle={this.handleReblogToggle}
|
||||
onSubscriptionToggle={this.handleSubscriptionToggle}
|
||||
onNotifyToggle={this.handleNotifyToggle}
|
||||
onReport={this.handleReport}
|
||||
onMute={this.handleMute}
|
||||
onBlockDomain={this.handleBlockDomain}
|
||||
|
|
|
@ -112,9 +112,9 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||
|
||||
onReblogToggle(account) {
|
||||
if (account.getIn(['relationship', 'showing_reblogs'])) {
|
||||
dispatch(followAccount(account.get('id'), false));
|
||||
dispatch(followAccount(account.get('id'), { reblogs: false }));
|
||||
} else {
|
||||
dispatch(followAccount(account.get('id'), true));
|
||||
dispatch(followAccount(account.get('id'), { reblogs: true }));
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -126,6 +126,14 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||
}
|
||||
},
|
||||
|
||||
onNotifyToggle(account) {
|
||||
if (account.getIn(['relationship', 'notifying'])) {
|
||||
dispatch(followAccount(account.get('id'), { notify: false }));
|
||||
} else {
|
||||
dispatch(followAccount(account.get('id'), { notify: true }));
|
||||
}
|
||||
},
|
||||
|
||||
// onEndorseToggle(account) {
|
||||
// if (account.getIn(['relationship', 'endorsed'])) {
|
||||
// dispatch(unpinAccount(account.get('id')));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
import classNames from 'classnames';
|
||||
|
@ -7,6 +8,7 @@ import Button from 'soapbox/components/button';
|
|||
import Icon from 'soapbox/components/icon';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import {
|
||||
followAccount,
|
||||
subscribeAccount,
|
||||
unsubscribeAccount,
|
||||
} from 'soapbox/actions/accounts';
|
||||
|
@ -32,6 +34,13 @@ const mapDispatchToProps = (dispatch) => ({
|
|||
dispatch(subscribeAccount(account.get('id')));
|
||||
}
|
||||
},
|
||||
onNotifyToggle(account) {
|
||||
if (account.getIn(['relationship', 'notifying'])) {
|
||||
dispatch(followAccount(account.get('id'), { notify: false }));
|
||||
} else {
|
||||
dispatch(followAccount(account.get('id'), { notify: true }));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default @connect(mapStateToProps, mapDispatchToProps)
|
||||
|
@ -40,15 +49,17 @@ class SubscriptionButton extends ImmutablePureComponent {
|
|||
|
||||
static propTypes = {
|
||||
account: ImmutablePropTypes.map,
|
||||
features: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
handleSubscriptionToggle = () => {
|
||||
this.props.onSubscriptionToggle(this.props.account);
|
||||
if (this.props.features.accountNotifies) this.props.onNotifyToggle(this.props.account);
|
||||
else this.props.onSubscriptionToggle(this.props.account);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { account, intl } = this.props;
|
||||
const subscribing = account.getIn(['relationship', 'subscribing']);
|
||||
const { account, intl, features } = this.props;
|
||||
const subscribing = features.accountNotifies ? account.getIn(['relationship', 'notifying']) : account.getIn(['relationship', 'subscribing']);
|
||||
const following = account.getIn(['relationship', 'following']);
|
||||
const requested = account.getIn(['relationship', 'requested']);
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@ export const getFeatures = createSelector([
|
|||
resetPasswordAPI: v.software === PLEROMA,
|
||||
exposableReactions: features.includes('exposable_reactions'),
|
||||
accountSubscriptions: v.software === PLEROMA && gte(v.version, '1.0.0'),
|
||||
accountNotifies: any([
|
||||
v.software === MASTODON && gte(v.compatVersion, '3.3.0'),
|
||||
v.software === PLEROMA && gte(v.version, '2.4.50'),
|
||||
]),
|
||||
unrestrictedLists: v.software === PLEROMA,
|
||||
accountByUsername: v.software === PLEROMA,
|
||||
profileDirectory: any([
|
||||
|
|
Ładowanie…
Reference in New Issue