From 7662b5ac8f5d8db849730a0e0c74b4535aaf6c13 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Fri, 27 Oct 2017 13:47:51 +0100 Subject: [PATCH] Unfinished, non-working changes to try and handle URL changes gracefully --- src/components/views/elements/AppTile.js | 26 +++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 0070af1fb2..7da0407c00 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -99,14 +99,27 @@ export default React.createClass({ }, componentWillMount: function() { + window.addEventListener('message', this._onMessage, false); + this.updateWidgetContent(); + }, + + // Update widget content + updateWidgetContent() { + this.setScalarToken(); + this.setState({ + loading: true, + }); + }, + + // Adds a scalar token to the widget URL, if required + setScalarToken() { if (!this.isScalarUrl()) { return; } // Fetch the token before loading the iframe as we need to mangle the URL - this.setState({ - loading: true, - }); - this._scalarClient = new ScalarAuthClient(); + if(! this._scalarClient) { + this._scalarClient = new ScalarAuthClient(); + } this._scalarClient.getScalarToken().done((token) => { // Append scalar_token as a query param this._scalarClient.scalarToken = token; @@ -128,13 +141,16 @@ export default React.createClass({ loading: false, }); }); - window.addEventListener('message', this._onMessage, false); }, componentWillUnmount() { window.removeEventListener('message', this._onMessage); }, + componentWillReceiveProps(nextProps) { + console.warn("Apptile", this.id, "got new props", this.url, nextProps.url); + }, + _onMessage(event) { if (this.props.type !== 'jitsi') { return;