Merge pull request #26 from ekiru/feature/manual-column-layout-setting
User-controlled multi-column/single-column overridesth-downstream
commit
098b360439
@ -0,0 +1,20 @@
|
|||||||
|
export const LOCAL_SETTING_CHANGE = 'LOCAL_SETTING_CHANGE';
|
||||||
|
|
||||||
|
export function changeLocalSetting(key, value) {
|
||||||
|
return dispatch => {
|
||||||
|
dispatch({
|
||||||
|
type: LOCAL_SETTING_CHANGE,
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch(saveLocalSettings());
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function saveLocalSettings() {
|
||||||
|
return (_, getState) => {
|
||||||
|
const localSettings = getState().get('localSettings').toJS();
|
||||||
|
localStorage.setItem('mastodon-settings', JSON.stringify(localSettings));
|
||||||
|
};
|
||||||
|
};
|
@ -0,0 +1,20 @@
|
|||||||
|
import { LOCAL_SETTING_CHANGE } from '../actions/local_settings';
|
||||||
|
import { STORE_HYDRATE } from '../actions/store';
|
||||||
|
import Immutable from 'immutable';
|
||||||
|
|
||||||
|
const initialState = Immutable.Map({
|
||||||
|
layout: 'auto',
|
||||||
|
});
|
||||||
|
|
||||||
|
const hydrate = (state, localSettings) => state.mergeDeep(localSettings);
|
||||||
|
|
||||||
|
export default function localSettings(state = initialState, action) {
|
||||||
|
switch(action.type) {
|
||||||
|
case STORE_HYDRATE:
|
||||||
|
return hydrate(state, action.state.get('localSettings'));
|
||||||
|
case LOCAL_SETTING_CHANGE:
|
||||||
|
return state.setIn(action.key, action.value);
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in new issue