]> cat aescling's git repositories - mastodon.git/commitdiff
Rename key to path in actions and reducers for settings (tootsuite pr #6105)
authorcwm <chriswmartin@protonmail.com>
Tue, 9 Jan 2018 15:48:14 +0000 (09:48 -0600)
committercwm <chriswmartin@protonmail.com>
Tue, 9 Jan 2018 15:48:14 +0000 (09:48 -0600)
app/javascript/flavours/glitch/actions/push_notifications/index.js
app/javascript/flavours/glitch/actions/push_notifications/setter.js
app/javascript/flavours/glitch/actions/settings.js
app/javascript/flavours/glitch/features/notifications/components/column_settings.js
app/javascript/flavours/glitch/features/notifications/containers/column_settings_container.js
app/javascript/flavours/glitch/reducers/push_notifications.js
app/javascript/flavours/glitch/reducers/settings.js

index 376b55b625f201e511dddbc8ed1988ac667df81e..2ffec500a9573ea4f9d25eae2ad9be01cca788b3 100644 (file)
@@ -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());
   };
 }
index a2cc41c5a3bbf8fcb1b23ca27ddb9e0c9366d6e9..5561766bff42b370c690736e39977730b864f62c 100644 (file)
@@ -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,
     });
   };
index 79adca18c6ea9092c641d42b10e65d323d7b935a..aeef43527e99799cdb098a3984049c9041becff4 100644 (file)
@@ -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 });
index 23545185c68f1e8591b2fc1ba9990e77bdf8d9be..d9638aaf35a958801501f74351cbf6f169091f96 100644 (file)
@@ -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 () {
index 95109fe4da5aec797153f6c5b33ab64e651596ce..9585ea556e07b04887516fe80fa7a7eb4db052d8 100644 (file)
@@ -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));
     }
   },
 
index 4eba2a5e86e5297b31ecbb3179636c7bac9467de..1b47ca962f908ef171231809c94c4dc8f20346e4 100644 (file)
@@ -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;
   }
index aaf7938df4da9b0caa58e61ac37c46ec1197f2a3..c04f262da29d371401305806f755076018212c41 100644 (file)
@@ -101,7 +101,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