From e20db416f2f8ec3f4fa341426d7dcc90ba61faf6 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Wed, 6 Dec 2017 16:44:41 +0000 Subject: [PATCH] Add field to bypass riot widget loading screen. --- src/WidgetMessaging.js | 2 +- src/components/views/elements/AppTile.js | 4 +++- src/components/views/rooms/AppsDrawer.js | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/WidgetMessaging.js b/src/WidgetMessaging.js index 74d5b91428..0f23413b5f 100644 --- a/src/WidgetMessaging.js +++ b/src/WidgetMessaging.js @@ -164,7 +164,7 @@ function stopListening() { function addEndpoint(widgetId, endpointUrl) { const u = URL.parse(endpointUrl); if (!u || !u.protocol || !u.host) { - console.warn("Invalid origin"); + console.warn("Invalid origin:", endpointUrl); return; } diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 1dbb7af586..7fe79e4684 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -52,11 +52,13 @@ export default React.createClass({ userId: React.PropTypes.string.isRequired, // UserId of the entity that added / modified the widget creatorUserId: React.PropTypes.string, + waitForIframeLoad: React.PropTypes.bool, }, getDefaultProps() { return { url: "", + waitForIframeLoad: true, }; }, @@ -71,7 +73,7 @@ export default React.createClass({ const hasPermissionToLoad = localStorage.getItem(widgetPermissionId); return { initialising: true, // True while we are mangling the widget URL - loading: true, // True while the iframe content is loading + loading: this.props.waitForIframeLoad, // True while the iframe content is loading widgetUrl: this._addWurlParams(newProps.url), widgetPermissionId: widgetPermissionId, // Assume that widget has permission to load if we are the user who diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index 423f345b1d..fca690e9d8 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -133,14 +133,18 @@ module.exports = React.createClass({ '$matrix_avatar_url': user ? MatrixClientPeg.get().mxcUrlToHttp(user.avatarUrl) : '', }; + app.id = appId; + app.name = app.name || app.type; + if (app.data) { Object.keys(app.data).forEach((key) => { params['$' + key] = app.data[key]; }); + + app.waitForIframeLoad = (app.data.waitForIframeLoad === 'false' ? false : true); + console.log("wait for iframe load:", app.waitForIframeLoad, app.id); } - app.id = appId; - app.name = app.name || app.type; app.url = this.encodeUri(app.url, params); app.creatorUserId = (sender && sender.userId) ? sender.userId : null; @@ -224,6 +228,7 @@ module.exports = React.createClass({ userId={this.props.userId} show={this.props.showApps} creatorUserId={app.creatorUserId} + waitForIframeLoad={app.waitForIframeLoad} />); });