about summary refs log tree commit diff
path: root/app/javascript/glitch/reducers/local_settings.js
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2017-07-12 01:02:51 -0700
committerkibigo! <marrus-sh@users.noreply.github.com>2017-07-12 01:02:51 -0700
commit297921fce570bfab413bab4e16a4ae694ecc4f28 (patch)
tree279bd98fe3102bd607c222f0497b7549fbb749d8 /app/javascript/glitch/reducers/local_settings.js
parent74eff5456c8655e6783ffe49a96042320af3848c (diff)
Moved glitch files to their own location ;)
Diffstat (limited to 'app/javascript/glitch/reducers/local_settings.js')
-rw-r--r--app/javascript/glitch/reducers/local_settings.js44
1 files changed, 44 insertions, 0 deletions
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;
+  }
+};