client/src/reducers/notesReducer.js
changeset 109 ef62de545a8d
parent 96 b58463d7dc8e
child 124 c77570164050
equal deleted inserted replaced
108:732adc46c8b8 109:ef62de545a8d
    18       const noteIndex = state.findIndex((note) => note.get('_id') === action.note.get('_id'));
    18       const noteIndex = state.findIndex((note) => note.get('_id') === action.note.get('_id'));
    19       return state.delete(noteIndex);
    19       return state.delete(noteIndex);
    20     case types.UPDATE_NOTE:
    20     case types.UPDATE_NOTE:
    21       const index = findNoteIndex(state, action.note.get('_id'));
    21       const index = findNoteIndex(state, action.note.get('_id'));
    22       const note = findNote(state, action.note.get('_id'));
    22       const note = findNote(state, action.note.get('_id'));
    23       const newNote = note
    23       let newNote = note;
    24         .set('plain', action.data.plain)
    24       Object.entries(action.data).forEach(([key, value]) => {
    25         .set('raw', action.data.raw)
    25         newNote = note.set(key, value)
    26         .set('html', action.data.html)
    26       });
    27         .set('categories', action.data.categories);
       
    28       return state.set(index, newNote);
    27       return state.set(index, newNote);
    29     case types.DELETE_SESSION:
    28     case types.DELETE_SESSION:
    30       return state.filter((note) => action.session.get('_id') !== note.session)
    29       return state.filter((note) => action.session.get('_id') !== note.session)
    31     default:
    30     default:
    32       return state;
    31       return state;