diff options
author | Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp> | 2018-01-02 21:50:54 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2018-01-02 13:50:54 +0100 |
commit | 3ba7cde38df980a715a6607b254093246cc9ebbd (patch) | |
tree | 7afa3bed8c9ea7cbbd752ab23c16fe5c1c6be249 /app | |
parent | ce854ed506fd5b44f0c842e02ba07adb1c83f8ba (diff) |
Rename key to path in actions and reducers for settings (#6105)
Diffstat (limited to 'app')
7 files changed, 15 insertions, 15 deletions
diff --git a/app/javascript/mastodon/actions/push_notifications/index.js b/app/javascript/mastodon/actions/push_notifications/index.js index 376b55b62..2ffec500a 100644 --- a/app/javascript/mastodon/actions/push_notifications/index.js +++ b/app/javascript/mastodon/actions/push_notifications/index.js @@ -15,9 +15,9 @@ export { register, }; -export function changeAlerts(key, value) { +export function changeAlerts(path, value) { return dispatch => { - dispatch(setAlerts(key, value)); + dispatch(setAlerts(path, value)); dispatch(saveSettings()); }; } diff --git a/app/javascript/mastodon/actions/push_notifications/setter.js b/app/javascript/mastodon/actions/push_notifications/setter.js index a2cc41c5a..5561766bf 100644 --- a/app/javascript/mastodon/actions/push_notifications/setter.js +++ b/app/javascript/mastodon/actions/push_notifications/setter.js @@ -23,11 +23,11 @@ export function clearSubscription () { }; } -export function setAlerts (key, value) { +export function setAlerts (path, value) { return dispatch => { dispatch({ type: SET_ALERTS, - key, + path, value, }); }; diff --git a/app/javascript/mastodon/actions/settings.js b/app/javascript/mastodon/actions/settings.js index 79adca18c..aeef43527 100644 --- a/app/javascript/mastodon/actions/settings.js +++ b/app/javascript/mastodon/actions/settings.js @@ -4,11 +4,11 @@ import { debounce } from 'lodash'; export const SETTING_CHANGE = 'SETTING_CHANGE'; export const SETTING_SAVE = 'SETTING_SAVE'; -export function changeSetting(key, value) { +export function changeSetting(path, value) { return dispatch => { dispatch({ type: SETTING_CHANGE, - key, + path, value, }); @@ -21,7 +21,7 @@ const debouncedSave = debounce((dispatch, getState) => { 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 })); }, 5000, { trailing: true }); diff --git a/app/javascript/mastodon/features/notifications/components/column_settings.js b/app/javascript/mastodon/features/notifications/components/column_settings.js index 23545185c..d9638aaf3 100644 --- a/app/javascript/mastodon/features/notifications/components/column_settings.js +++ b/app/javascript/mastodon/features/notifications/components/column_settings.js @@ -14,8 +14,8 @@ export default class ColumnSettings extends React.PureComponent { onClear: PropTypes.func.isRequired, }; - onPushChange = (key, checked) => { - this.props.onChange(['push', ...key], checked); + onPushChange = (path, checked) => { + this.props.onChange(['push', ...path], checked); } render () { diff --git a/app/javascript/mastodon/features/notifications/containers/column_settings_container.js b/app/javascript/mastodon/features/notifications/containers/column_settings_container.js index f4c63fee6..e9cef0a7b 100644 --- a/app/javascript/mastodon/features/notifications/containers/column_settings_container.js +++ b/app/javascript/mastodon/features/notifications/containers/column_settings_container.js @@ -18,11 +18,11 @@ const mapStateToProps = state => ({ const mapDispatchToProps = (dispatch, { intl }) => ({ - onChange (key, checked) { - if (key[0] === 'push') { - dispatch(changePushNotifications(key.slice(1), checked)); + onChange (path, checked) { + if (path[0] === 'push') { + dispatch(changePushNotifications(path.slice(1), checked)); } else { - dispatch(changeSetting(['notifications', ...key], checked)); + dispatch(changeSetting(['notifications', ...path], checked)); } }, diff --git a/app/javascript/mastodon/reducers/push_notifications.js b/app/javascript/mastodon/reducers/push_notifications.js index c15b38fe4..85628c6b1 100644 --- a/app/javascript/mastodon/reducers/push_notifications.js +++ b/app/javascript/mastodon/reducers/push_notifications.js @@ -44,7 +44,7 @@ export default function push_subscriptions(state = initialState, action) { case CLEAR_SUBSCRIPTION: return initialState; case SET_ALERTS: - return state.setIn(action.key, action.value); + return state.setIn(action.path, action.value); default: return state; } diff --git a/app/javascript/mastodon/reducers/settings.js b/app/javascript/mastodon/reducers/settings.js index 5817cf49b..390b2a13a 100644 --- a/app/javascript/mastodon/reducers/settings.js +++ b/app/javascript/mastodon/reducers/settings.js @@ -93,7 +93,7 @@ export default function settings(state = initialState, action) { return hydrate(state, action.state.get('settings')); case SETTING_CHANGE: return state - .setIn(action.key, action.value) + .setIn(action.path, action.value) .set('saved', false); case COLUMN_ADD: return state |