From 297921fce570bfab413bab4e16a4ae694ecc4f28 Mon Sep 17 00:00:00 2001 From: kibigo! Date: Wed, 12 Jul 2017 01:02:51 -0700 Subject: Moved glitch files to their own location ;) --- app/javascript/glitch/reducers/local_settings.js | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 app/javascript/glitch/reducers/local_settings.js (limited to 'app/javascript/glitch/reducers') diff --git a/app/javascript/glitch/reducers/local_settings.js b/app/javascript/glitch/reducers/local_settings.js new file mode 100644 index 000000000..db99f2c46 --- /dev/null +++ b/app/javascript/glitch/reducers/local_settings.js @@ -0,0 +1,44 @@ +// Package imports // +import Immutable from 'immutable'; + +// Mastodon imports // +import { STORE_HYDRATE } from '../../mastodon/actions/store'; + +// Our imports // +import { LOCAL_SETTING_CHANGE } from '../actions/local_settings'; + +const initialState = Immutable.fromJS({ + layout : 'auto', + stretch : true, + collapsed : { + enabled : true, + auto : { + all : false, + notifications : true, + lengthy : true, + replies : false, + media : false, + }, + backgrounds : { + user_backgrounds : false, + preview_images : false, + }, + }, + media : { + letterbox : true, + fullwidth : true, + }, +}); + +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('local_settings')); + case LOCAL_SETTING_CHANGE: + return state.setIn(action.key, action.value); + default: + return state; + } +}; -- cgit