diff options
author | kibigo! <marrus-sh@users.noreply.github.com> | 2017-07-13 03:26:08 -0700 |
---|---|---|
committer | kibigo! <marrus-sh@users.noreply.github.com> | 2017-07-13 03:26:08 -0700 |
commit | 35fda84ba830415a575b5f99f7405353ab8d3c93 (patch) | |
tree | 60f24d1b5c36605c8ed10c6c8b736c457cd1b9f9 /app/javascript/glitch/actions | |
parent | 5770d461b21cf5b6a8adcaa44d19832e11289960 (diff) |
Documentation pt. I
Diffstat (limited to 'app/javascript/glitch/actions')
-rw-r--r-- | app/javascript/glitch/actions/local_settings.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/app/javascript/glitch/actions/local_settings.js b/app/javascript/glitch/actions/local_settings.js index 18e0c245c..479b5841d 100644 --- a/app/javascript/glitch/actions/local_settings.js +++ b/app/javascript/glitch/actions/local_settings.js @@ -1,5 +1,60 @@ +/* + +`actions/local_settings` +======================== + +> For more information on the contents of this file, please contact: +> +> - kibigo! [@kibi@glitch.social] + +This file provides our Redux actions related to local settings. It +consists of the following: + + - __`changesLocalSetting(key, value)` :__ + Changes the local setting with the given `key` to the given + `value`. `key` **MUST** be an array of strings, as required by + `Immutable.Map.prototype.getIn()`. + + - __`saveLocalSettings()` :__ + Saves the local settings to `localStorage` as a JSON object. We + shouldn't ever need to call this ourselves. + +*/ + + /* * * * */ + +/* + +Constants +--------- + +We provide the following constants: + + - __`LOCAL_SETTING_CHANGE` :__ + This string constant is used to dispatch a setting change to our + reducer in `reducers/local_settings`, where the setting is + actually changed. + +*/ + export const LOCAL_SETTING_CHANGE = 'LOCAL_SETTING_CHANGE'; + /* * * * */ + +/* + +`changeLocalSetting(key, value)` +-------------------------------- + +Changes the local setting with the given `key` to the given `value`. +`key` **MUST** be an array of strings, as required by +`Immutable.Map.prototype.getIn()`. + +To accomplish this, we just dispatch a `LOCAL_SETTING_CHANGE` to our +reducer in `reducers/local_settings`. + +*/ + export function changeLocalSetting(key, value) { return dispatch => { dispatch({ @@ -12,6 +67,24 @@ export function changeLocalSetting(key, value) { }; }; + /* * * * */ + +/* + +`saveLocalSettings()` +--------------------- + +Saves the local settings to `localStorage` as a JSON object. +`changeLocalSetting()` calls this whenever it changes a setting. We +shouldn't ever need to call this ourselves. + +> __TODO :__ +> Right now `saveLocalSettings()` doesn't keep track of which user +> is currently signed in, but it might be better to give each user +> their *own* local settings. + +*/ + export function saveLocalSettings() { return (_, getState) => { const localSettings = getState().get('local_settings').toJS(); |