From 616465748b1bb924e112c38d1783b3b1e869c220 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Fri, 27 Oct 2017 23:16:35 +0900 Subject: [PATCH] Use a Mattermost animation icon when loading a page in the app --- src/browser/components/MattermostView.jsx | 30 +++++++++++++++---- src/browser/css/components/MattermostView.css | 19 ++++++++++-- test/specs/browser/index_test.js | 5 ++-- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/browser/components/MattermostView.jsx b/src/browser/components/MattermostView.jsx index 3bb97a47..2f045a04 100644 --- a/src/browser/components/MattermostView.jsx +++ b/src/browser/components/MattermostView.jsx @@ -30,7 +30,8 @@ const MattermostView = createReactClass({ return { errorInfo: null, isContextMenuAdded: false, - reloadTimeoutID: null + reloadTimeoutID: null, + isLoaded: false }; }, @@ -44,6 +45,12 @@ const MattermostView = createReactClass({ var self = this; var webview = findDOMNode(this.refs.webview); + webview.addEventListener('did-finish-load', () => { + self.setState({ + isLoaded: true + }); + }); + webview.addEventListener('did-fail-load', (e) => { console.log(self.props.name, 'webview did-fail-load', e); if (e.errorCode === -3) { // An operation was aborted (due to user action). @@ -51,7 +58,8 @@ const MattermostView = createReactClass({ } self.setState({ - errorInfo: e + errorInfo: e, + isLoaded: true }); function reload() { window.removeEventListener('online', reload); @@ -161,7 +169,8 @@ const MattermostView = createReactClass({ clearTimeout(this.state.reloadTimeoutID); this.setState({ errorInfo: null, - reloadTimeoutID: null + reloadTimeoutID: null, + isLoaded: false }); var webview = findDOMNode(this.refs.webview); webview.reload(); @@ -235,16 +244,25 @@ const MattermostView = createReactClass({ if (this.props.withTab) { classNames.push('mattermostView-with-tab'); } - if (!this.props.active) { + if (!this.props.active || this.state.errorInfo) { classNames.push('mattermostView-hidden'); } + const loadingImage = !this.state.errorInfo && this.props.active && !this.state.isLoaded ? ( + + ) : null; + return ( -
+
{ errorView } + { loadingImage } visible.should.be.true). isVisible('#mattermostView1').then((visible) => visible.should.be.false). click('#teamTabItem1'). - pause(1000). - isVisible('#mattermostView1').then((visible) => visible.should.be.true). - isVisible('#mattermostView0').then((visible) => visible.should.be.false); + waitForVisible('#mattermostView1', 2000). + isVisible('#mattermostView0').then((visible) => visible.should.be.false); }); it('should show error when using incorrect URL', () => {