Better settings handling with localSettings (new!)

This commit is contained in:
kibigo!
2017-06-24 19:12:34 -07:00
parent 4c37f629bc
commit da05cde721
5 changed files with 52 additions and 6 deletions

View File

@@ -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));
};
};