diff options
author | Samy Pessé <samypesse@gmail.com> | 2017-02-17 19:01:28 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2017-02-17 19:01:28 +0100 |
commit | 21884d80c311ee7888d4a59c19423643b798d29a (patch) | |
tree | 25357f7a320b3702d0b3f9cc01f381a495925751 /packages/gitbook-core/src/reducers | |
parent | 4e3e3e515de5da4a9926ccae38256381f2a32714 (diff) | |
download | gitbook-21884d80c311ee7888d4a59c19423643b798d29a.zip gitbook-21884d80c311ee7888d4a59c19423643b798d29a.tar.gz gitbook-21884d80c311ee7888d4a59c19423643b798d29a.tar.bz2 |
Define actions for low level gitbook.com API
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); }; |