@@ -2,9 +2,12 @@ import { fromJS } from 'immutable';
2
2
3
3
const CREATE = 'COMMENTS_STORE:CREATE' ;
4
4
const REMOVE = 'COMMENTS_STORE:REMOVE' ;
5
+ const SET_LOADING = 'COMMENTS_STORE:SET_LOADING' ;
5
6
6
7
export const initialState = fromJS ( {
7
- meta : { }
8
+ meta : {
9
+ loading : false ,
10
+ } ,
8
11
} ) ;
9
12
10
13
const create = ( state , action ) => {
@@ -15,6 +18,9 @@ const remove = (state, action) => {
15
18
return state . delete ( action . id ) ;
16
19
} ;
17
20
21
+ const setLoading = ( state , action ) => {
22
+ return state . setIn ( [ 'meta' , 'loading' ] , action . loading ) ;
23
+ } ;
18
24
19
25
export default ( state , action ) => {
20
26
if ( ! state ) {
@@ -26,6 +32,8 @@ export default (state, action) => {
26
32
return create ( state , action ) ;
27
33
case REMOVE :
28
34
return remove ( state , action ) ;
35
+ case SET_LOADING :
36
+ return setLoading ( state , action ) ;
29
37
default :
30
38
return state ;
31
39
}
@@ -39,7 +47,12 @@ const removeComment = (id) => {
39
47
return { type : REMOVE , id } ;
40
48
} ;
41
49
50
+ const setLoadingComments = ( loading ) => {
51
+ return { type : SET_LOADING , loading} ;
52
+ } ;
53
+
42
54
export const actions = {
43
55
createComments,
44
56
removeComment,
57
+ setLoadingComments,
45
58
} ;
0 commit comments