From 7fb85c251b86d3c9d9c8aa3cad4cebb3ae2b2b31 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Wed, 28 Sep 2016 14:12:01 -0400 Subject: [PATCH] auto autorefresh to preferences, save autorefresh server side --- client/constants.js | 1 + client/modules/IDE/actions/preferences.js | 43 ++++++++++++++++++++-- client/modules/IDE/components/Toolbar.js | 8 +++- client/modules/IDE/pages/IDEView.js | 6 ++- client/modules/IDE/reducers/preferences.js | 5 ++- server/models/user.js | 3 +- 6 files changed, 59 insertions(+), 7 deletions(-) diff --git a/client/constants.js b/client/constants.js index 3c22e79c..e440c93f 100644 --- a/client/constants.js +++ b/client/constants.js @@ -84,6 +84,7 @@ export const SET_TOAST_TEXT = 'SET_TOAST_TEXT'; export const SET_THEME = 'SET_THEME'; export const SET_UNSAVED_CHANGES = 'SET_UNSAVED_CHANGES'; +export const SET_AUTOREFRESH = 'SET_AUTOREFRESH'; export const DETECT_INFINITE_LOOPS = 'DETECT_INFINITE_LOOPS'; export const RESET_INFINITE_LOOPS = 'RESET_INFINITE_LOOPS'; diff --git a/client/modules/IDE/actions/preferences.js b/client/modules/IDE/actions/preferences.js index 6b3964ef..5d8bc4b1 100644 --- a/client/modules/IDE/actions/preferences.js +++ b/client/modules/IDE/actions/preferences.js @@ -138,9 +138,46 @@ export function setTextOutput(value) { } export function setTheme(value) { - return { - type: ActionTypes.SET_THEME, - value + // return { + // type: ActionTypes.SET_THEME, + // value + // }; + return (dispatch, getState) => { + dispatch({ + type: ActionTypes.SET_THEME, + value + }); + const state = getState(); + if (state.user.authenticated) { + const formParams = { + preferences: { + theme: value + } + }; + updatePreferences(formParams, dispatch); + } + }; +} + +export function setAutorefresh(value) { + // return { + // type: ActionTypes.SET_AUTOREFRESH, + // value + // }; + return (dispatch, getState) => { + dispatch({ + type: ActionTypes.SET_AUTOREFRESH, + value + }); + const state = getState(); + if (state.user.authenticated) { + const formParams = { + preferences: { + autorefresh: value + } + }; + updatePreferences(formParams, dispatch); + } }; } diff --git a/client/modules/IDE/components/Toolbar.js b/client/modules/IDE/components/Toolbar.js index 6a4f773d..e2c952e2 100644 --- a/client/modules/IDE/components/Toolbar.js +++ b/client/modules/IDE/components/Toolbar.js @@ -73,6 +73,10 @@ class Toolbar extends React.Component { { + this.props.setAutorefresh(event.target.checked); + }} />