From c780cd05a8b918cc91926a697faf374eaa55da7b Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 26 Jun 2018 16:33:28 +0100 Subject: [PATCH] Change argument order of setRoomWidget So when deleting a widget we can just omit the ones we don't need --- src/CallHandler.js | 2 +- src/ScalarMessaging.js | 2 +- src/components/views/elements/AppTile.js | 6 +----- src/utils/WidgetUtils.js | 6 +++--- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/CallHandler.js b/src/CallHandler.js index b470585f36..7403483e36 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -458,7 +458,7 @@ function _startCallApp(roomId, type) { Date.now() ); - WidgetUtils.setRoomWidget(widgetId, 'jitsi', widgetUrl, 'Jitsi', widgetData, roomId).then(() => { + WidgetUtils.setRoomWidget(roomId, widgetId, 'jitsi', widgetUrl, 'Jitsi', widgetData).then(() => { console.log('Jitsi widget added'); }).catch((e) => { console.error(e); diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index 41224c266f..3325044b84 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -336,7 +336,7 @@ function setWidget(event, roomId) { if (!roomId) { sendError(event, _t('Missing roomId.'), null); } - WidgetUtils.setRoomWidget(widgetId, widgetType, widgetUrl, widgetName, widgetData, roomId).then(() => { + WidgetUtils.setRoomWidget(roomId, widgetId, widgetType, widgetUrl, widgetName, widgetData).then(() => { sendResponse(event, { success: true, }); diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index ea303a96b2..7b69057e3e 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -321,12 +321,8 @@ export default class AppTile extends React.Component { this.setState({deleting: true}); WidgetUtils.setRoomWidget( - this.props.id, - null, - null, - null, - null, this.props.room.roomId, + this.props.id, ).catch((e) => { console.error('Failed to delete widget', e); }).finally(() => { diff --git a/src/utils/WidgetUtils.js b/src/utils/WidgetUtils.js index 924500b97d..ab5b5b0130 100644 --- a/src/utils/WidgetUtils.js +++ b/src/utils/WidgetUtils.js @@ -210,7 +210,7 @@ export default class WidgetUtils { console.error(`$widgetId is non-configurable`); } - const addingWidget = widgetUrl !== null; + const addingWidget = Boolean(widgetUrl); // Add new widget / update if (addingWidget) { @@ -234,10 +234,10 @@ export default class WidgetUtils { }); } - static setRoomWidget(widgetId, widgetType, widgetUrl, widgetName, widgetData, roomId) { + static setRoomWidget(roomId, widgetId, widgetType, widgetUrl, widgetName, widgetData) { let content; - const addingWidget = widgetUrl !== null; + const addingWidget = Boolean(widgetUrl); if (addingWidget) { content = {