Rename key to path in actions and reducers for settings (tootsuite pr #6105)

This commit is contained in:
cwm 2018-01-09 09:48:14 -06:00
parent d12ce24054
commit cf027c74db
7 changed files with 15 additions and 15 deletions

View file

@ -15,9 +15,9 @@ export {
register, register,
}; };
export function changeAlerts(key, value) { export function changeAlerts(path, value) {
return dispatch => { return dispatch => {
dispatch(setAlerts(key, value)); dispatch(setAlerts(path, value));
dispatch(saveSettings()); dispatch(saveSettings());
}; };
} }

View file

@ -23,11 +23,11 @@ export function clearSubscription () {
}; };
} }
export function setAlerts (key, value) { export function setAlerts (path, value) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: SET_ALERTS, type: SET_ALERTS,
key, path,
value, value,
}); });
}; };

View file

@ -4,11 +4,11 @@ import { debounce } from 'lodash';
export const SETTING_CHANGE = 'SETTING_CHANGE'; export const SETTING_CHANGE = 'SETTING_CHANGE';
export const SETTING_SAVE = 'SETTING_SAVE'; export const SETTING_SAVE = 'SETTING_SAVE';
export function changeSetting(key, value) { export function changeSetting(path, value) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: SETTING_CHANGE, type: SETTING_CHANGE,
key, path,
value, value,
}); });
@ -21,7 +21,7 @@ const debouncedSave = debounce((dispatch, getState) => {
return; return;
} }
const data = getState().get('settings').filter((_, key) => key !== 'saved').toJS(); const data = getState().get('settings').filter((_, path) => path !== 'saved').toJS();
axios.put('/api/web/settings', { data }).then(() => dispatch({ type: SETTING_SAVE })); axios.put('/api/web/settings', { data }).then(() => dispatch({ type: SETTING_SAVE }));
}, 5000, { trailing: true }); }, 5000, { trailing: true });

View file

@ -14,8 +14,8 @@ export default class ColumnSettings extends React.PureComponent {
onClear: PropTypes.func.isRequired, onClear: PropTypes.func.isRequired,
}; };
onPushChange = (key, checked) => { onPushChange = (path, checked) => {
this.props.onChange(['push', ...key], checked); this.props.onChange(['push', ...path], checked);
} }
render () { render () {

View file

@ -18,11 +18,11 @@ const mapStateToProps = state => ({
const mapDispatchToProps = (dispatch, { intl }) => ({ const mapDispatchToProps = (dispatch, { intl }) => ({
onChange (key, checked) { onChange (path, checked) {
if (key[0] === 'push') { if (path[0] === 'push') {
dispatch(changePushNotifications(key.slice(1), checked)); dispatch(changePushNotifications(path.slice(1), checked));
} else { } else {
dispatch(changeSetting(['notifications', ...key], checked)); dispatch(changeSetting(['notifications', ...path], checked));
} }
}, },

View file

@ -44,7 +44,7 @@ export default function push_subscriptions(state = initialState, action) {
case CLEAR_SUBSCRIPTION: case CLEAR_SUBSCRIPTION:
return initialState; return initialState;
case SET_ALERTS: case SET_ALERTS:
return state.setIn(action.key, action.value); return state.setIn(action.path, action.value);
default: default:
return state; return state;
} }

View file

@ -101,7 +101,7 @@ export default function settings(state = initialState, action) {
return hydrate(state, action.state.get('settings')); return hydrate(state, action.state.get('settings'));
case SETTING_CHANGE: case SETTING_CHANGE:
return state return state
.setIn(action.key, action.value) .setIn(action.path, action.value)
.set('saved', false); .set('saved', false);
case COLUMN_ADD: case COLUMN_ADD:
return state return state