From cbf52e00d29513791a2eb733c8abc00a1a2f179e Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 10 May 2018 16:43:10 +0100 Subject: [PATCH 1/2] Update widget 'widgetData' key to 'data' to match spec. --- src/FromWidgetPostMessageApi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FromWidgetPostMessageApi.js b/src/FromWidgetPostMessageApi.js index ad1f1acbbd..c9c9d5c3de 100644 --- a/src/FromWidgetPostMessageApi.js +++ b/src/FromWidgetPostMessageApi.js @@ -137,12 +137,12 @@ export default class FromWidgetPostMessageApi { }); } else if (action === 'm.sticker') { // console.warn('Got sticker message from widget', widgetId); - dis.dispatch({action: 'm.sticker', data: event.data.widgetData, widgetId: event.data.widgetId}); + dis.dispatch({action: 'm.sticker', data: event.data.data, widgetId: event.data.widgetId}); } else if (action === 'integration_manager_open') { // Close the stickerpicker dis.dispatch({action: 'stickerpicker_close'}); // Open the integration manager - const data = event.data.widgetData; + const data = event.data.data; const integType = (data && data.integType) ? data.integType : null; const integId = (data && data.integId) ? data.integId : null; IntegrationManager.open(integType, integId); From 5cb892bf3cb23e1f49e413aeb81b70eecade6aa5 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 10 May 2018 18:06:00 +0100 Subject: [PATCH 2/2] Allow use of either 'data' or 'widgetData' fields for the time being. --- src/FromWidgetPostMessageApi.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/FromWidgetPostMessageApi.js b/src/FromWidgetPostMessageApi.js index c9c9d5c3de..13ffb4a74b 100644 --- a/src/FromWidgetPostMessageApi.js +++ b/src/FromWidgetPostMessageApi.js @@ -137,12 +137,15 @@ export default class FromWidgetPostMessageApi { }); } else if (action === 'm.sticker') { // console.warn('Got sticker message from widget', widgetId); - dis.dispatch({action: 'm.sticker', data: event.data.data, widgetId: event.data.widgetId}); + // NOTE -- The widgetData field is deprecated (in favour of the 'data' field) and will be removed eventually + const data = event.data.data || event.data.widgetData; + dis.dispatch({action: 'm.sticker', data: data, widgetId: event.data.widgetId}); } else if (action === 'integration_manager_open') { // Close the stickerpicker dis.dispatch({action: 'stickerpicker_close'}); // Open the integration manager - const data = event.data.data; + // NOTE -- The widgetData field is deprecated (in favour of the 'data' field) and will be removed eventually + const data = event.data.data || event.data.widgetData; const integType = (data && data.integType) ? data.integType : null; const integId = (data && data.integId) ? data.integId : null; IntegrationManager.open(integType, integId);