client/src/components/Session.js
changeset 137 279e1dffa213
parent 129 d48946d164c6
child 138 a1fb2ced3049
--- a/client/src/components/Session.js	Thu Aug 03 19:12:25 2017 +0200
+++ b/client/src/components/Session.js	Thu Aug 03 23:04:33 2017 +0200
@@ -11,7 +11,8 @@
 import * as sessionsActions from '../actions/sessionsActions';
 import * as notesActions from '../actions/notesActions';
 import * as userActions from '../actions/userActions';
-import { ActionEnum } from '../constants';
+import { getSession, getSessionNotes } from '../selectors/coreSelectors';
+import { getAutoSubmit } from '../selectors/authSelectors';
 
 class Session extends Component {
   render() {
@@ -56,18 +57,12 @@
 
   const sessionId = props.match.params.id;
 
-  const sessions = state.get('sessions');
-  const notes = state.get('notes');
-  const autoSubmit = state.get('autoSubmit');
-
-  const currentSession = sessions.find(session => session._id === sessionId);
-  const currentNotes = notes.filter(note => {
-        return (note.get('session') === sessionId && note.get('action') !== ActionEnum.DELETED);
-    }).sortBy( n => n.get('startedAt') );
+  const autoSubmit = getAutoSubmit(state);
+  const currentSession = getSession(sessionId, state);
+  const currentNotes = getSessionNotes(sessionId, state);
 
   return {
     currentSession,
-    sessions,
     notes: currentNotes,
     autoSubmit
   };