Skip to content

Commit 1366a5c

Browse files
committed
immutable - Simplify moving from lane to another
1 parent 67e6502 commit 1366a5c

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

immutable_app/app/reducers/lanes.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,14 @@ export default function lanes(state = initialState, action) {
8888
return state.map((lane) => {
8989
if(lane === sourceLane) {
9090
// get rid of the source note
91-
return Map(Object.assign({}, lane, {
92-
notes: lane.get('notes').count() > 1 ? List(lane.get('notes').slice(0, sourceNoteIndex).concat(
93-
lane.get('notes').slice(sourceNoteIndex + 1)
94-
)): List()
95-
}));
91+
return lane.deleteIn(['notes', sourceNoteIndex]);
9692
}
9793

9894
if(lane === targetLane) {
9995
// and move it to target
100-
return Map(Object.assign({}, lane, {
101-
notes: List(lane.get('notes').slice(0, targetNoteIndex).concat(
102-
[sourceId]
103-
).concat(
104-
lane.get('notes').slice(targetNoteIndex)
105-
))
106-
}));
96+
return lane.updateIn(['notes'], notes => notes.insert(
97+
targetNoteIndex, sourceId
98+
));
10799
}
108100

109101
return lane;

0 commit comments

Comments
 (0)