diff options
Diffstat (limited to 'packages/gitbook-core/src/reducers/summary.js')
-rw-r--r-- | packages/gitbook-core/src/reducers/summary.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/gitbook-core/src/reducers/summary.js b/packages/gitbook-core/src/reducers/summary.js new file mode 100644 index 0000000..60568ef --- /dev/null +++ b/packages/gitbook-core/src/reducers/summary.js @@ -0,0 +1,28 @@ +const { Record, List } = require('immutable'); + +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); +}; |