application/redux/reducers/application-reducers.js
- import Immutable from 'immutable';
- import {
- APPLICATION_NOTIFY_UPDATES,
- APPLICATION_DID_NOTIFY_UPDATES,
- APPLICATION_SET_VERSION,
- APPLICATION_IS_CONNECTED,
- APPLICATION_IS_DIRTY,
- APPLICATION_SET_SETTINGS,
- APPLICATION_SET_SETPLUGINS
- } from '../actions/application-actions';
-
- export function application(state = null, action) {
- if (state == null) {
- state = {
- version: '0.0.0',
- doNotifyChanges: false,
- connectedState: false,
- isDirty: false,
- settings: Immutable.fromJS({}),
- plugins: Immutable.fromJS([])
- }
- }
-
- switch(action.type) {
- case APPLICATION_IS_DIRTY:
- // GIMME MY MONEY!
- return Object.assign({}, state, {
- isDirty: action.payload.isDirty
- });
- case APPLICATION_SET_VERSION:
- return Object.assign({}, state, {
- version: action.payload.version
- });
- case APPLICATION_NOTIFY_UPDATES:
- return Object.assign({}, state, {
- doNotifyChanges: true
- });
- case APPLICATION_DID_NOTIFY_UPDATES:
- return Object.assign({}, state, {
- doNotifyChanges: false
- });
- case APPLICATION_IS_CONNECTED:
- return Object.assign({}, state, {
- connectedState: action.payload.connectedState
- });
- case APPLICATION_SET_SETTINGS:
- return Object.assign({}, state, {
- settings: action.payload.settings
- });
- case APPLICATION_SET_SETPLUGINS:
- return Object.assign({}, state, {
- plugins: action.payload.plugins
- });
- }
-
- return state;
- }