From a408b985049a7f7ce816dd423dfa60d3fa240c19 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Fri, 29 Dec 2017 14:34:52 +0000 Subject: [PATCH] Set widget ID on WidgetMessaging instance. --- src/WidgetMessaging.js | 3 ++- src/components/views/elements/AppTile.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/WidgetMessaging.js b/src/WidgetMessaging.js index 37dd6b8be4..7918e435cb 100644 --- a/src/WidgetMessaging.js +++ b/src/WidgetMessaging.js @@ -170,8 +170,9 @@ if (!global.mxWidgetMessagingMessageEndpoints) { } export default class WidgetMessaging extends MatrixPostMessageApi { - constructor(targetWindow) { + constructor(widgetId, targetWindow) { super(targetWindow); + this.widgetId = widgetId; } exec(action) { diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 8032b9d76b..2fbb30ff90 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -334,11 +334,11 @@ export default React.createClass({ */ _onLoaded() { // console.warn("App frame", this.refs.appFrame.contentWindow); - this.widgetMessaging = new WidgetMessaging(this.refs.appFrame.contentWindow); + this.widgetMessaging = new WidgetMessaging(this.props.id, this.refs.appFrame.contentWindow); this.widgetMessaging.startListening(); this.widgetMessaging.addEndpoint(this.props.id, this.props.url); this.widgetMessaging.getCapabilities().then((capabilities) => { - console.log("Got widget capabilities", this.widgetId, capabilities); + console.log("Got widget capabilities", this.props.id, capabilities); capabilities = capabilities || []; this.setState({capabilities}); }).catch((err) => {