client/src/reducers/notesReducer.js
changeset 29 4cfeabef7d5e
parent 12 48ddaa42b810
child 58 f16a080e0bc4
equal deleted inserted replaced
28:abf9f3ff2635 29:4cfeabef7d5e
     1 import Immutable from 'immutable';
     1 import Immutable from 'immutable';
     2 // import PouchDB from 'pouchdb';
       
     3 
       
     4 import * as types from '../constants/actionTypes';
     2 import * as types from '../constants/actionTypes';
     5 import noteRecord from '../store/noteRecord';
     3 import noteRecord from '../store/noteRecord';
     6 
       
     7 // const db = new PouchDB('notes');
       
     8 
       
     9 // db.allDocs({ include_docs: true, descending: true }, function(err, doc) {
       
    10 //   console.log(doc.rows)
       
    11 // });
       
    12 
     4 
    13 export default (state = Immutable.List([]), action) => {
     5 export default (state = Immutable.List([]), action) => {
    14   switch (action.type) {
     6   switch (action.type) {
    15     case types.ADD_NOTE:
     7     case types.ADD_NOTE:
    16       return state.push(new noteRecord(action.note));
     8       return state.push(new noteRecord(action.note));
       
     9     case types.LOAD_NOTES_BY_SESSION:
       
    10       return action.notes;
    17     default:
    11     default:
    18       return state;
    12       return state;
    19   }
    13   }
    20 };
    14 };