| author | Alexandre Segura <mex.zktk@gmail.com> |
| Fri, 23 Jun 2017 10:16:49 +0200 | |
| changeset 79 | 772b73e31069 |
| parent 66 | f402435be429 |
| child 80 | b3a02ea6d097 |
| permissions | -rw-r--r-- |
|
3
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
import Immutable from 'immutable'; |
|
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
import * as types from '../constants/actionTypes'; |
|
62
b2514a9bcd49
migrate to redux-offline + various optimisation
ymh <ymh.work@gmail.com>
parents:
59
diff
changeset
|
3 |
import NoteRecord from '../store/noteRecord'; |
|
3
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
|
|
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
export default (state = Immutable.List([]), action) => { |
|
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
switch (action.type) { |
|
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
case types.ADD_NOTE: |
|
62
b2514a9bcd49
migrate to redux-offline + various optimisation
ymh <ymh.work@gmail.com>
parents:
59
diff
changeset
|
8 |
return state.push(new NoteRecord(action.note)); |
|
79
772b73e31069
Introduce note editing, allow deleting note.
Alexandre Segura <mex.zktk@gmail.com>
parents:
66
diff
changeset
|
9 |
case types.DELETE_NOTE: |
|
772b73e31069
Introduce note editing, allow deleting note.
Alexandre Segura <mex.zktk@gmail.com>
parents:
66
diff
changeset
|
10 |
const noteIndex = state.findIndex((note) => note.get('_id') === action.note.get('_id')); |
|
772b73e31069
Introduce note editing, allow deleting note.
Alexandre Segura <mex.zktk@gmail.com>
parents:
66
diff
changeset
|
11 |
return state.delete(noteIndex); |
|
3
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
default: |
|
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
return state; |
|
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
} |
|
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
}; |