client/src/components/Sessions.js
changeset 59 1eb52770eefa
parent 58 f16a080e0bc4
--- a/client/src/components/Sessions.js	Mon Jun 19 21:37:33 2017 +0200
+++ b/client/src/components/Sessions.js	Mon Jun 19 21:46:21 2017 +0200
@@ -6,14 +6,17 @@
 import '../App.css';
 import Navbar from './Navbar';
 import * as sessionsActions from '../actions/sessionsActions';
-import uuidV1 from 'uuid/v1';
 
 class Sessions extends Component {
 
   createSession = () => {
-    const sessionId = uuidV1();
-    this.props.sessionsActions.createSession(sessionId);
-    this.props.history.push('/sessions/' + sessionId);
+    this.props.sessionsActions.createSession();
+  }
+
+  componentDidUpdate = () => {
+    if (this.props.currentSession) {
+      this.props.history.push('/sessions/' + this.props.currentSession._id)
+    }
   }
 
   render() {
@@ -43,9 +46,8 @@
 
 function mapStateToProps(state, props) {
   return {
-    // currentSession: state.get('currentSession'),
-    // sessions: state.get('sessions')
-    sessions: state['sessions']
+    currentSession: state.get('currentSession'),
+    sessions: state.get('sessions')
   };
 }