about summary refs log tree commit diff
path: root/app/javascript/glitch/actions
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/glitch/actions')
-rw-r--r--app/javascript/glitch/actions/local_settings.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/javascript/glitch/actions/local_settings.js b/app/javascript/glitch/actions/local_settings.js
new file mode 100644
index 000000000..18e0c245c
--- /dev/null
+++ b/app/javascript/glitch/actions/local_settings.js
@@ -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('local_settings').toJS();
+    localStorage.setItem('mastodon-settings', JSON.stringify(localSettings));
+  };
+};