diff -r 6542f93cdc0d -r c77570164050 client/src/reducers/sessionsReducer.js --- a/client/src/reducers/sessionsReducer.js Wed Jul 19 17:03:40 2017 +0200 +++ b/client/src/reducers/sessionsReducer.js Thu Jul 20 11:23:08 2017 +0200 @@ -3,27 +3,35 @@ import SessionRecord from '../store/sessionRecord'; export const sessions = (state = Immutable.List([]), action) => { - let sessionIndex; switch (action.type) { - case types.CREATE_SESSION: + + case types.CREATE_SESSION: { return state.push(new SessionRecord(action.session)); - case types.UPDATE_SESSION: + } + case types.UPDATE_SESSION: { const sessionToUpdate = state.find(session => session === action.session); - sessionIndex = state.indexOf(action.session); + const sessionIndex = state.indexOf(action.session); if (sessionIndex === -1) { return state; } - const updatedSession = sessionToUpdate.merge(action.values); + const updatedSession = sessionToUpdate.merge(action.values, {modified: true}); return state.set(sessionIndex, updatedSession); - case types.DELETE_SESSION: - sessionIndex = state.indexOf(action.session); + } + case types.DO_DELETE_SESSION: { + return state.filter((note) => action.session.get('_id') !== note.session) + } + case types.DELETE_SESSION: { + const sessionIndex = state.indexOf(action.session); if (sessionIndex === -1) { return state; } - return state.delete(sessionIndex); - case types.LOAD_SESSIONS: + const deletedSession = state.get(sessionIndex); + return state.set(sessionIndex, deletedSession.merge({deleted:true, modified:true})); + } + case types.LOAD_SESSIONS: { return action.sessions; + } default: return state; }