equal
deleted
inserted
replaced
1 import Immutable from 'immutable'; |
1 import Immutable from 'immutable'; |
2 import * as types from '../constants/actionTypes'; |
2 import * as types from '../constants/actionTypes'; |
3 import UserRecord from '../store/userRecord'; |
3 import UserRecord from '../store/userRecord'; |
|
4 import GroupRecord from '../store/groupRecord'; |
4 import asyncRequest from '../constants/asyncRequest'; |
5 import asyncRequest from '../constants/asyncRequest'; |
5 import uuidV4 from 'uuid/v4'; |
6 import uuidV4 from 'uuid/v4'; |
|
7 import _ from 'lodash'; |
6 |
8 |
7 export const isAuthenticated = (state = false, action) => { |
9 export const isAuthenticated = (state = false, action) => { |
8 switch (action.type) { |
10 switch (action.type) { |
9 case types.AUTH_DEAUTHENTICATE: |
11 case types.AUTH_DEAUTHENTICATE: |
10 case types.AUTH_LOGOUT: |
12 case types.AUTH_LOGOUT: |
101 } |
103 } |
102 |
104 |
103 export const groups = (state = Immutable.List([]), action) => { |
105 export const groups = (state = Immutable.List([]), action) => { |
104 switch (action.type) { |
106 switch (action.type) { |
105 case types.GROUP_LOAD_SUCCESS: |
107 case types.GROUP_LOAD_SUCCESS: |
106 return Immutable.List(action.groups.results); |
108 return Immutable.List( |
|
109 action.groups.map((group) => GroupRecord({ |
|
110 ...(_.omit(group, 'is_personal')), |
|
111 isPersonal: group['is_personal'] |
|
112 })) |
|
113 ); |
107 case types.GROUP_CREATE_SUCCESS: |
114 case types.GROUP_CREATE_SUCCESS: |
108 return state.push(action.group); |
115 return state.push(GroupRecord({ |
|
116 ...(_.omit(action.group, 'is_personal')), |
|
117 isPersonal: action.group['is_personal'] |
|
118 })); |
|
119 case types.AUTH_LOGOUT: { |
|
120 return Immutable.List(); // empty note list on logout |
|
121 } |
109 default: |
122 default: |
110 return state |
123 return state |
111 } |
124 } |
112 } |
125 } |
113 |
126 |