EditProfile: restore muteStrangers checkbox
This commit is contained in:
parent
a9cd4014f2
commit
9fc4f0120e
2 changed files with 30 additions and 22 deletions
|
@ -2,7 +2,7 @@ import { unescape } from 'lodash';
|
||||||
import React, { useState, useEffect, useMemo } from 'react';
|
import React, { useState, useEffect, useMemo } from 'react';
|
||||||
import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
// import { updateNotificationSettings } from 'soapbox/actions/accounts';
|
import { updateNotificationSettings } from 'soapbox/actions/accounts';
|
||||||
import { patchMe } from 'soapbox/actions/me';
|
import { patchMe } from 'soapbox/actions/me';
|
||||||
import snackbar from 'soapbox/actions/snackbar';
|
import snackbar from 'soapbox/actions/snackbar';
|
||||||
import {
|
import {
|
||||||
|
@ -47,13 +47,6 @@ const messages = defineMessages({
|
||||||
// field ? field : ImmutableMap({ name: '', value: '' }),
|
// field ? field : ImmutableMap({ name: '', value: '' }),
|
||||||
// )
|
// )
|
||||||
// );
|
// );
|
||||||
//
|
|
||||||
// /** HTML unescape for special chars, eg <br> */
|
|
||||||
// const unescapeParams = (map, params) => (
|
|
||||||
// params.reduce((map, param) => (
|
|
||||||
// map.set(param, unescape(map.get(param)))
|
|
||||||
// ), map)
|
|
||||||
// );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Profile metadata `name` and `value`.
|
* Profile metadata `name` and `value`.
|
||||||
|
@ -153,11 +146,14 @@ const EditProfile: React.FC = () => {
|
||||||
|
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
const [data, setData] = useState<AccountCredentials>({});
|
const [data, setData] = useState<AccountCredentials>({});
|
||||||
|
const [muteStrangers, setMuteStrangers] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (account) {
|
if (account) {
|
||||||
const credentials = accountToCredentials(account);
|
const credentials = accountToCredentials(account);
|
||||||
|
const strangerNotifications = account.getIn(['pleroma', 'notification_settings', 'block_from_strangers']) === true;
|
||||||
setData(credentials);
|
setData(credentials);
|
||||||
|
setMuteStrangers(strangerNotifications);
|
||||||
}
|
}
|
||||||
}, [account?.id]);
|
}, [account?.id]);
|
||||||
|
|
||||||
|
@ -169,15 +165,21 @@ const EditProfile: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit: React.FormEventHandler = (event) => {
|
const handleSubmit: React.FormEventHandler = (event) => {
|
||||||
const credentials = dispatch(patchMe(data, true));
|
const promises = [];
|
||||||
/* Bad API url, was causing errors in the promise call below blocking the success message after making edits. */
|
|
||||||
/* const notifications = dispatch(updateNotificationSettings({
|
promises.push(dispatch(patchMe(data, true)));
|
||||||
block_from_strangers: this.state.stranger_notifications || false,
|
|
||||||
})); */
|
if (features.muteStrangers) {
|
||||||
|
promises.push(
|
||||||
|
dispatch(updateNotificationSettings({
|
||||||
|
block_from_strangers: muteStrangers,
|
||||||
|
})).catch(console.error),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
Promise.all([credentials /*notifications*/]).then(() => {
|
Promise.all(promises).then(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
dispatch(snackbar.success(intl.formatMessage(messages.success)));
|
dispatch(snackbar.success(intl.formatMessage(messages.success)));
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
@ -383,14 +385,14 @@ const EditProfile: React.FC = () => {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/*
|
{features.muteStrangers && (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
label={<FormattedMessage id='edit_profile.fields.stranger_notifications_label' defaultMessage='Block notifications from strangers' />}
|
label={<FormattedMessage id='edit_profile.fields.stranger_notifications_label' defaultMessage='Block notifications from strangers' />}
|
||||||
hint={<FormattedMessage id='edit_profile.hints.stranger_notifications' defaultMessage='Only show notifications from people you follow' />}
|
hint={<FormattedMessage id='edit_profile.hints.stranger_notifications' defaultMessage='Only show notifications from people you follow' />}
|
||||||
checked={this.state.stranger_notifications}
|
checked={muteStrangers}
|
||||||
onChange={this.handleCheckboxChange('stranger_notifications')}
|
onChange={(e) => setMuteStrangers(e.target.checked)}
|
||||||
/>
|
/>
|
||||||
*/}
|
)}
|
||||||
|
|
||||||
{features.profileDirectory && (
|
{features.profileDirectory && (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
|
|
@ -311,6 +311,12 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
// v.software === PLEROMA && gte(v.version, '2.1.0'),
|
// v.software === PLEROMA && gte(v.version, '2.1.0'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ability to hide notifications from people you don't follow.
|
||||||
|
* @see PUT /api/pleroma/notification_settings
|
||||||
|
*/
|
||||||
|
muteStrangers: v.software === PLEROMA,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add private notes to accounts.
|
* Add private notes to accounts.
|
||||||
* @see POST /api/v1/accounts/:id/note
|
* @see POST /api/v1/accounts/:id/note
|
||||||
|
|
Loading…
Reference in a new issue