From 7f6eddf3c736503627bcb992726e16203dd7537a Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Wed, 1 Feb 2017 08:11:36 +0200 Subject: [PATCH] Add loader during redirect to external site after oauth --- src/services/authFlow/AuthFlow.js | 10 ++++++++-- src/services/authFlow/CompleteState.js | 6 +----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/services/authFlow/AuthFlow.js b/src/services/authFlow/AuthFlow.js index ec361ba..102b1d5 100644 --- a/src/services/authFlow/AuthFlow.js +++ b/src/services/authFlow/AuthFlow.js @@ -1,6 +1,7 @@ import { routeActions } from 'react-router-redux'; import logger from 'services/logger'; +import loader from 'services/loader'; import RegisterState from './RegisterState'; import LoginState from './LoginState'; @@ -63,8 +64,13 @@ export default class AuthFlow { run(actionId, payload) { if (actionId === 'redirect') { - location.href = payload; - return; + loader.show(); + + return new Promise(() => { + // do not resolve promise to make loader visible and + // overcome app rendering + location.href = payload; + }); } if (!this.actions[actionId]) { diff --git a/src/services/authFlow/CompleteState.js b/src/services/authFlow/CompleteState.js index 15ae37e..82d5f93 100644 --- a/src/services/authFlow/CompleteState.js +++ b/src/services/authFlow/CompleteState.js @@ -82,11 +82,7 @@ export default class CompleteState extends AbstractState { if (resp.redirectUri.indexOf('static_page') === 0) { context.setState(new FinishState()); } else { - return new Promise(() => { - // do not resolve promise to make loader visible and - // overcome app rendering - context.run('redirect', resp.redirectUri); - }); + return context.run('redirect', resp.redirectUri); } }, (resp) => { if (resp.unauthorized) {