blob: 0179eccf991d3341ad0d64097736e8c8d50990f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
const { Record, List } = require('immutable');
const FileState = require('./file');
class SummaryArticle extends Record({
title: '',
depth: 0,
path: '',
ref: '',
level: '',
articles: List()
}) {
constructor(state) {
super({
...state,
articles: (new List(state.articles))
.map(article => new SummaryArticle(article))
});
}
}
class SummaryPart extends Record({
title: '',
articles: List()
}) {
constructor(state) {
super({
...state,
articles: (new List(state.articles))
.map(article => new SummaryArticle(article))
});
}
}
class SummaryState extends Record({
file: new FileState(),
parts: List()
}) {
constructor(state = {}) {
super({
...state,
file: new FileState(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);
};
|