Better settings handling with localSettings (new!)
This commit is contained in:
20
app/javascript/mastodon/reducers/local_settings.js
Normal file
20
app/javascript/mastodon/reducers/local_settings.js
Normal file
@@ -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;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user