From 7daef3b082716b779af0c54d6d8632e624167b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 21 Jul 2015 15:30:00 +0200 Subject: [PATCH] small fix and more comments --- js/components/ascribe_forms/form_login.js | 18 +++++++++++------- .../slides_container.js | 11 +++++++++-- js/components/register_piece.js | 11 +++++++---- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/js/components/ascribe_forms/form_login.js b/js/components/ascribe_forms/form_login.js index 76eb904e..24b0eb93 100644 --- a/js/components/ascribe_forms/form_login.js +++ b/js/components/ascribe_forms/form_login.js @@ -73,16 +73,20 @@ let LoginForm = React.createClass({ // register_piece is listening to the changes of the user_store. UserActions.fetchCurrentUser() .then(() => { - /* Taken from http://stackoverflow.com/a/14916411 */ - /* - We actually have to trick the Browser into showing the "save password" dialog - as Chrome expects the login page to be reloaded after the login. - Users on Stack Overflow claim this is a bug in chrome and should be fixed in the future. - Until then, we redirect the HARD way, but reloading the whole page using window.location - */ if(this.props.redirectOnLoginSuccess) { + /* Taken from http://stackoverflow.com/a/14916411 */ + /* + We actually have to trick the Browser into showing the "save password" dialog + as Chrome expects the login page to be reloaded after the login. + Users on Stack Overflow claim this is a bug in chrome and should be fixed in the future. + Until then, we redirect the HARD way, but reloading the whole page using window.location + */ window.location = AppConstants.baseUrl + 'collection'; } else if(this.props.onLogin) { + // In some instances we want to give a callback to an outer container, + // to show that the one login action the user triggered actually went through. + // We can not do this by listening on a store's state as it wouldn't really tell us + // if the user did log in or was just fetching the user's data again this.props.onLogin(); } }) diff --git a/js/components/ascribe_slides_container/slides_container.js b/js/components/ascribe_slides_container/slides_container.js index 6b4bbe2c..ad883d0c 100644 --- a/js/components/ascribe_slides_container/slides_container.js +++ b/js/components/ascribe_slides_container/slides_container.js @@ -82,8 +82,15 @@ let SlidesContainer = React.createClass({ // if slideNum is within the range of slides and none of the previous cases // where matched, we can actually do transitions } else if(slideNum >= 0 || slideNum < React.Children.count(this.props.children)) { - if(slideNum !== this.state.slideNum - 1 && !document.referrer) { - + + if(slideNum !== this.state.slideNum - 1) { + // Bootstrapping the component, getInitialState is called once to save + // the tabs history length. + // In order to know if we already pushed a new state on the history stack or not, + // we're comparing the old history length with the new one and if it didn't change then + // we push a new state on it ONCE (ever). + // Otherwise, we're able to use the browsers history.forward() method + // to keep the stack clean if(this.state.historyLength === window.history.length) { this.transitionTo(this.getPathname(), null, {slide_num: slideNum}); } else { diff --git a/js/components/register_piece.js b/js/components/register_piece.js index dc168a35..20826b7d 100644 --- a/js/components/register_piece.js +++ b/js/components/register_piece.js @@ -81,6 +81,13 @@ let RegisterPiece = React.createClass( { onChange(state) { this.setState(state); + + if(this.state.currentUser && this.state.currentUser.email) { + // we should also make the fineuploader component editable again + this.setState({ + isFineUploaderActive: true + }); + } }, handleSuccess(response){ @@ -166,10 +173,6 @@ let RegisterPiece = React.createClass( { // register_piece slide if(this.state.currentUser && this.state.currentUser.email) { window.history.back(); - // we should also make the fineuploader component editable again - this.setState({ - isFineUploaderActive: true - }); } },