From d20aebfbd76ef038d3c96322ffe3b9d52b56bdeb Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 4 Jan 2018 18:58:55 +0000 Subject: [PATCH] Correctly handle sticker message events. --- src/WidgetMessaging.js | 3 +-- src/components/views/elements/AppTile.js | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/WidgetMessaging.js b/src/WidgetMessaging.js index 1b66dd89dd..4e64cedbc1 100644 --- a/src/WidgetMessaging.js +++ b/src/WidgetMessaging.js @@ -325,8 +325,7 @@ export default class WidgetMessaging extends MatrixPostMessageApi { version: WIDGET_API_VERSION, }); } else if (action === 'sticker_message') { - console.warn('got widget sticker message', widgetId); - dis.dispatch({action: 'sticker_message', data: event.data.data}); + dis.dispatch({action: 'sticker_message', data: event.data.widgetData, widgetId: event.data.widgetId}); } else { console.warn("Widget postMessage event unhandled"); this.sendError(event, {message: "The postMessage was unhandled"}); diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 9e24c12cd5..49e747b05e 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -350,16 +350,18 @@ export default React.createClass({ }, _onAction(payload) { - switch (payload) { - case payload.action === 'sticker_message': - if (this._hasCapability('sticker_message')) { - dis.dispatch({action: 'post_sticker_message', data: payload.data}); - } else { - console.warn('Ignoring sticker message. Invalid capability'); - } - break; - } - }, + if (payload.widgetId === this.props.id) { + switch (payload.action) { + case 'sticker_message': + if (this._hasCapability('sticker_message')) { + dis.dispatch({action: 'post_sticker_message', data: payload.data}); + } else { + console.warn('Ignoring sticker message. Invalid capability'); + } + break; + } + } + }, /** * Set remote content title on AppTile