client/src/components/SessionList.js
changeset 133 6f3078f7fd47
parent 129 d48946d164c6
child 137 279e1dffa213
--- a/client/src/components/SessionList.js	Tue Aug 01 12:20:14 2017 +0200
+++ b/client/src/components/SessionList.js	Thu Aug 03 09:44:37 2017 +0200
@@ -18,7 +18,15 @@
 
   createSession = () => {
     const sessionId = uuidV1();
-    this.props.sessionsActions.createSession(sessionId);
+    const groupName = (this.props.currentUser)?this.props.currentUser.get('default_group'):null;
+    let protocol = null;
+    if(groupName != null) {
+      const group = this.props.groups.find((g) => g.name === groupName);
+      if(group) {
+        protocol = group.get('protocol');
+      }
+    }
+    this.props.sessionsActions.createSession(sessionId, groupName, protocol);
     this.props.history.push('/sessions/' + sessionId);
   }
 
@@ -86,13 +94,15 @@
 
 function mapStateToProps(state, props) {
   return {
-    sessions: state.get('sessions').filter(session => session.get('action') !== ActionEnum.DELETED)
+    sessions: state.get('sessions').filter(session => session.get('action') !== ActionEnum.DELETED),
+    currentUser: state.getIn(['authStatus', 'currentUser']),
+    groups: state.get('groups')
   };
 }
 
 function mapDispatchToProps(dispatch) {
   return {
-    sessionsActions: bindActionCreators(sessionsActions, dispatch)
+    sessionsActions: bindActionCreators(sessionsActions, dispatch),
   }
 }