diff --git a/app/soapbox/features/edit_profile/index.tsx b/app/soapbox/features/edit_profile/index.tsx
index d654f95cc9..27539d627c 100644
--- a/app/soapbox/features/edit_profile/index.tsx
+++ b/app/soapbox/features/edit_profile/index.tsx
@@ -2,7 +2,7 @@ import { unescape } from 'lodash';
import React, { useState, useEffect, useMemo } from 'react';
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 snackbar from 'soapbox/actions/snackbar';
import {
@@ -47,13 +47,6 @@ const messages = defineMessages({
// field ? field : ImmutableMap({ name: '', value: '' }),
// )
// );
-//
-// /** HTML unescape for special chars, eg
*/
-// const unescapeParams = (map, params) => (
-// params.reduce((map, param) => (
-// map.set(param, unescape(map.get(param)))
-// ), map)
-// );
/**
* Profile metadata `name` and `value`.
@@ -153,11 +146,14 @@ const EditProfile: React.FC = () => {
const [isLoading, setLoading] = useState(false);
const [data, setData] = useState({});
+ const [muteStrangers, setMuteStrangers] = useState(false);
useEffect(() => {
if (account) {
const credentials = accountToCredentials(account);
+ const strangerNotifications = account.getIn(['pleroma', 'notification_settings', 'block_from_strangers']) === true;
setData(credentials);
+ setMuteStrangers(strangerNotifications);
}
}, [account?.id]);
@@ -169,15 +165,21 @@ const EditProfile: React.FC = () => {
};
const handleSubmit: React.FormEventHandler = (event) => {
- const credentials = dispatch(patchMe(data, true));
- /* Bad API url, was causing errors in the promise call below blocking the success message after making edits. */
- /* const notifications = dispatch(updateNotificationSettings({
- block_from_strangers: this.state.stranger_notifications || false,
- })); */
+ const promises = [];
+
+ promises.push(dispatch(patchMe(data, true)));
+
+ if (features.muteStrangers) {
+ promises.push(
+ dispatch(updateNotificationSettings({
+ block_from_strangers: muteStrangers,
+ })).catch(console.error),
+ );
+ }
setLoading(true);
- Promise.all([credentials /*notifications*/]).then(() => {
+ Promise.all(promises).then(() => {
setLoading(false);
dispatch(snackbar.success(intl.formatMessage(messages.success)));
}).catch(() => {
@@ -383,14 +385,14 @@ const EditProfile: React.FC = () => {
/>
)}
- {/*
- }
- hint={}
- checked={this.state.stranger_notifications}
- onChange={this.handleCheckboxChange('stranger_notifications')}
- />
- */}
+ {features.muteStrangers && (
+ }
+ hint={}
+ checked={muteStrangers}
+ onChange={(e) => setMuteStrangers(e.target.checked)}
+ />
+ )}
{features.profileDirectory && (
{
// 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.
* @see POST /api/v1/accounts/:id/note