diff options
Diffstat (limited to 'packages/gitbook-core/src/reducers')
-rw-r--r-- | packages/gitbook-core/src/reducers/api.js | 15 | ||||
-rw-r--r-- | packages/gitbook-core/src/reducers/summary.js | 26 |
2 files changed, 17 insertions, 24 deletions
diff --git a/packages/gitbook-core/src/reducers/api.js b/packages/gitbook-core/src/reducers/api.js new file mode 100644 index 0000000..72f5f33 --- /dev/null +++ b/packages/gitbook-core/src/reducers/api.js @@ -0,0 +1,15 @@ +const StateApi = require('../models/StateApi'); +const ACTION_TYPES = require('../actions/TYPES'); + +module.exports = (state, action) => { + state = StateApi.create(state); + + switch (action.type) { + case ACTION_TYPES.API_USER_FETCHED: + return state.merge({ + currentUser: action.user + }); + default: + return state; + } +}; diff --git a/packages/gitbook-core/src/reducers/summary.js b/packages/gitbook-core/src/reducers/summary.js index 60568ef..c20d27a 100644 --- a/packages/gitbook-core/src/reducers/summary.js +++ b/packages/gitbook-core/src/reducers/summary.js @@ -1,28 +1,6 @@ -const { Record, List } = require('immutable'); +const StateSummary = require('../models/StateSummary'); -const File = require('../models/File'); -const SummaryPart = require('../models/SummaryPart'); - - -class SummaryState extends Record({ - file: new File(), - parts: List() -}) { - constructor(state = {}) { - super({ - ...state, - file: new File(state.file), - parts: (new List(state.parts)) - .map(article => new SummaryPart(article)) - }); - } - - static create(state) { - return state instanceof SummaryState ? - state : new SummaryState(state); - } -} module.exports = (state, action) => { - return SummaryState.create(state); + return StateSummary.create(state); }; |