Verified Commit 4b041c15 authored by Haelwenn's avatar Haelwenn
Browse files

initial_state: sync notifications.shows with pleroma notification_settings

lodash suggestion from Alex Gleason
parent cfefd0ae
Pipeline #27911 passed with stage
in 4 minutes and 47 seconds
......@@ -25,7 +25,10 @@ const debouncedSave = debounce((dispatch, getState) => {
const data = getState().get('settings').filter((_, path) => path !== 'saved').toJS();
api(getState).put('/api/pleroma/notification_settings', { exclude_types: excludeTypesFromSettings(getState()) });
api(getState).put(
'/api/pleroma/notification_settings',
{ exclude_types: excludeTypesFromSettings(getState()) }
).catch(error => dispatch(showAlertForError(error)));
api(getState).put('/api/web/settings', { data })
.then(() => dispatch({ type: SETTING_SAVE }))
......
import { get, set } from 'lodash';
const maybeSetNotificationsSettings = result => {
const me = get(result, ['meta', 'me']);
if(!me) return;
const showTypes = get(result, ['settings', 'notifications', 'shows'], {});
const excludeTypes = get(result, ['accounts', me, 'pleroma', 'notification_settings', 'exclude_types'], []);
excludeTypes.forEach(x => showTypes[x] = false);
set(result, ['settings', 'notifications', 'shows'], showTypes);
}
const element = document.getElementById('initial-state');
const initialState = element && function () {
const result = JSON.parse(element.textContent);
......@@ -6,6 +19,7 @@ const initialState = element && function () {
} catch (e) {
result.local_settings = {};
}
maybeSetNotificationsSettings(result);
return result;
}();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment