client/src/reducers/sessionsReducer.js
changeset 62 b2514a9bcd49
parent 59 1eb52770eefa
child 93 469da13402e2
--- a/client/src/reducers/sessionsReducer.js	Tue Jun 20 12:11:57 2017 +0200
+++ b/client/src/reducers/sessionsReducer.js	Tue Jun 20 14:13:15 2017 +0200
@@ -1,26 +1,27 @@
 import Immutable from 'immutable';
 import * as types from '../constants/actionTypes';
+import SessionRecord from '../store/sessionRecord';
 
-export const currentSession = (state = null, action) => {
-  switch (action.type) {
-    case types.CREATE_SESSION:
-      return action.session;
-    default:
-      return state;
-  }
-};
+// export const currentSession = (state = null, action) => {
+//   switch (action.type) {
+//     case types.CREATE_SESSION:
+//       return action.session;
+//     default:
+//       return state;
+//   }
+// };
 
 export const sessions = (state = Immutable.List([]), action) => {
   switch (action.type) {
     case types.CREATE_SESSION:
-      return state.push(action.session);
+      return state.push(new SessionRecord(action.session));
     case types.UPDATE_SESSION:
       const sessionToUpdate = state.find(session => session === action.session);
       const sessionIndex = state.indexOf(action.session);
       if (sessionIndex === -1) {
         return state;
       }
-      const updatedSession = Object.assign({}, sessionToUpdate, action.values);
+      const updatedSession = sessionToUpdate.merge(action.values);
       return state.set(sessionIndex, updatedSession);
     case types.LOAD_SESSIONS:
       return action.sessions;