diff --git a/embark-ui/src/actions/index.js b/embark-ui/src/actions/index.js
index ea343cda3..53fe2cbe9 100644
--- a/embark-ui/src/actions/index.js
+++ b/embark-ui/src/actions/index.js
@@ -30,6 +30,14 @@ export const changeTheme = {
failure: (error) => action(CHANGE_THEME[FAILURE], {error})
};
+export const FETCH_THEME = createRequestTypes('FETCH_THEME');
+export const fetchTheme = {
+ request: () => action(FETCH_THEME[REQUEST]),
+ success: (theme) => action(FETCH_THEME[SUCCESS], {theme}),
+ failure: () => action(FETCH_THEME[FAILURE])
+};
+
+
export const FETCH_CREDENTIALS = createRequestTypes('FETCH_CREDENTIALS');
export const fetchCredentials = {
request: () => action(FETCH_CREDENTIALS[REQUEST]),
@@ -104,11 +112,15 @@ export const COMMANDS = createRequestTypes('COMMANDS');
export const commands = {
post: (command) => action(COMMANDS[REQUEST], {command}),
success: (command, payload) => {
- return action(COMMANDS[SUCCESS], {processLogs: [{
- timestamp: new Date().getTime(),
- name: EMBARK_PROCESS_NAME,
- msg: `console> ${payload.command}
${ansiToHtml(command.result)}`
- }]})
+ return action(COMMANDS[SUCCESS], {
+ processLogs: [
+ {
+ timestamp: new Date().getTime(),
+ name: EMBARK_PROCESS_NAME,
+ msg: `console> ${payload.command}
${ansiToHtml(command.result)}`
+ }
+ ]
+ });
},
failure: (error) => action(COMMANDS[FAILURE], {error})
};
diff --git a/embark-ui/src/containers/AppContainer.js b/embark-ui/src/containers/AppContainer.js
index de578970d..d9e9b2d7c 100644
--- a/embark-ui/src/containers/AppContainer.js
+++ b/embark-ui/src/containers/AppContainer.js
@@ -11,7 +11,7 @@ import {
processes as processesAction,
versions as versionsAction,
plugins as pluginsAction,
- changeTheme
+ changeTheme, fetchTheme
} from '../actions';
import { getCredentials, getAuthenticationError, getVersions, getTheme } from '../reducers/selectors';
@@ -39,6 +39,7 @@ class AppContainer extends Component {
componentDidMount() {
this.props.fetchCredentials();
+ this.props.fetchTheme();
}
requireAuthentication() {
@@ -113,6 +114,7 @@ export default withRouter(connect(
fetchProcesses: processesAction.request,
fetchVersions: versionsAction.request,
fetchPlugins: pluginsAction.request,
- changeTheme: changeTheme.request
+ changeTheme: changeTheme.request,
+ fetchTheme: fetchTheme.request
},
)(AppContainer));
diff --git a/embark-ui/src/reducers/index.js b/embark-ui/src/reducers/index.js
index 943853a30..a7d38503b 100644
--- a/embark-ui/src/reducers/index.js
+++ b/embark-ui/src/reducers/index.js
@@ -1,6 +1,6 @@
import {combineReducers} from 'redux';
import {REQUEST, SUCCESS, FAILURE, CONTRACT_COMPILE, FILES, LOGOUT, AUTHENTICATE,
- FETCH_CREDENTIALS, UPDATE_BASE_ETHER, CHANGE_THEME} from "../actions";
+ FETCH_CREDENTIALS, UPDATE_BASE_ETHER, CHANGE_THEME, FETCH_THEME} from "../actions";
import {EMBARK_PROCESS_NAME} from '../constants';
const BN_FACTOR = 10000;
@@ -86,7 +86,7 @@ const filtrer = {
},
processLogs: function(processLog, index, self) {
if (processLog.id !== undefined) {
- return index === self.findIndex((p) => p.id === processLog.id) && index <= MAX_ELEMENTS
+ return index === self.findIndex((p) => p.id === processLog.id) && index <= MAX_ELEMENTS;
}
return true;
},
@@ -224,7 +224,7 @@ function baseEther(state = '1', action) {
}
function theme(state='dark', action) {
- if (action.type === CHANGE_THEME[REQUEST]) {
+ if (action.type === CHANGE_THEME[REQUEST] || action.type === FETCH_THEME[SUCCESS]) {
return action.theme;
}
return state;
diff --git a/embark-ui/src/sagas/index.js b/embark-ui/src/sagas/index.js
index a5e8cb876..a645d30f0 100644
--- a/embark-ui/src/sagas/index.js
+++ b/embark-ui/src/sagas/index.js
@@ -50,6 +50,8 @@ export const deleteCurrentFile = doRequest.bind(null, null, storage.deleteCurren
export const fetchCredentials = doRequest.bind(null, actions.fetchCredentials, storage.fetchCredentials);
export const saveCredentials = doRequest.bind(null, actions.saveCredentials, storage.saveCredentials);
export const logout = doRequest.bind(null, actions.logout, storage.logout);
+export const changeTheme = doRequest.bind(null, actions.changeTheme, storage.changeTheme);
+export const fetchTheme = doRequest.bind(null, actions.fetchTheme, storage.fetchTheme);
export function *watchFetchTransaction() {
@@ -185,6 +187,14 @@ export function *watchAuthenticate() {
yield takeEvery(actions.AUTHENTICATE[actions.REQUEST], authenticate);
}
+export function *watchChangeTheme() {
+ yield takeEvery(actions.CHANGE_THEME[actions.REQUEST], changeTheme);
+}
+
+export function *watchFetchTheme() {
+ yield takeEvery(actions.FETCH_THEME[actions.REQUEST], fetchTheme);
+}
+
export function *watchAuthenticateSuccess() {
yield takeEvery(actions.AUTHENTICATE[actions.SUCCESS], saveCredentials);
}
@@ -341,6 +351,8 @@ export default function *root() {
fork(watchAuthenticate),
fork(watchAuthenticateSuccess),
fork(watchLogout),
+ fork(watchFetchTheme),
+ fork(watchChangeTheme),
fork(watchListenGasOracle)
]);
}
diff --git a/embark-ui/src/services/storage.js b/embark-ui/src/services/storage.js
index a1d374c3a..7141707ea 100644
--- a/embark-ui/src/services/storage.js
+++ b/embark-ui/src/services/storage.js
@@ -19,7 +19,7 @@ export function deleteCurrentFile() {
}
export function saveCredentials({token, host}) {
- const credentials = {token, host}
+ const credentials = {token, host};
return new Promise(function(resolve) {
localStorage.setItem('credentials', JSON.stringify(credentials));
resolve({response: {data: credentials}});
@@ -39,3 +39,16 @@ export function logout() {
resolve({response: true});
});
}
+
+export function changeTheme({theme}) {
+ return new Promise(function(resolve) {
+ localStorage.setItem('theme', theme);
+ resolve({response: {data: theme}});
+ });
+}
+
+export function fetchTheme() {
+ return new Promise(function(resolve) {
+ resolve({response: {data: localStorage.getItem('theme')}});
+ });
+}