diff --git a/lib/gui/app.js b/lib/gui/app.js index 57de765354..c68ce4c006 100644 --- a/lib/gui/app.js +++ b/lib/gui/app.js @@ -298,11 +298,18 @@ app.controller('HeaderController', function(SelectionStateModel, OSOpenExternalS }); -app.controller('StateController', function($state) { +app.controller('StateController', function($rootScope, $state) { /** * @param {string} state - state page */ this.is = $state.is; + /** + * @param {function} func - function to pass $rootScope to + */ + this.onStateChange = (func) => { + $rootScope.$on('$stateChangeSuccess', func); + }; + }); diff --git a/lib/gui/components/safe-webview/safe-webview.js b/lib/gui/components/safe-webview/safe-webview.js index bc31812bf5..eca4c2839a 100644 --- a/lib/gui/components/safe-webview/safe-webview.js +++ b/lib/gui/components/safe-webview/safe-webview.js @@ -84,6 +84,14 @@ class SafeWebview extends react.PureComponent { this.refs.webview.addEventListener('new-window', this.constructor.newWindow); this.refs.webview.addEventListener('console-message', this.constructor.consoleMessage); + if (this.props.onStateChange) { + this.props.onStateChange((event, toState, toParams, fromState) => { + if (fromState.name === 'success' && this.state.shouldLoad) { + this.refs.webview.src = this.props.src; + this.refs.webview.reload(); + } + }); + } } } @@ -164,7 +172,12 @@ SafeWebview.propTypes = { /** * @summary The website source URL */ - src: propTypes.string.isRequired + src: propTypes.string.isRequired, + + /** + * @summary Inject Angular functionality + */ + onStateChange: propTypes.func }; diff --git a/lib/gui/index.html b/lib/gui/index.html index 53aaec801b..a335597a15 100644 --- a/lib/gui/index.html +++ b/lib/gui/index.html @@ -57,7 +57,8 @@ isFinish: state.is('success') }"> + src="'https://etcher.io/success-banner/'" + on-state-change="state.onStateChange">