From 11915b0cdf51ef8c15cbf573c7cd3e364aea1afc Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 2 Apr 2018 10:02:41 +0100 Subject: [PATCH] Fix user widget event type. Add comments for clarity. --- src/ScalarMessaging.js | 6 +++++- src/WidgetUtils.js | 2 +- src/utils/widgets.js | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index dad1bdf6f6..123d02159e 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -350,7 +350,7 @@ function setWidget(event, roomId) { content: content, sender: client.getUserId(), stateKey: widgetId, - type: 'im.vector.modular.widgets', + type: 'm.widget', id: widgetId, }; } @@ -370,6 +370,8 @@ function setWidget(event, roomId) { if (widgetUrl === null) { // widget is being deleted content = {}; } + // TODO - Room widgets need to be moved to 'm.widget' state events + // https://docs.google.com/document/d/1uPF7XWY_dXTKVKV7jZQ2KmsI19wn9-kFRgQ1tFQP7wQ/edit?usp=sharing client.sendStateEvent(roomId, "im.vector.modular.widgets", content, widgetId).done(() => { sendResponse(event, { success: true, @@ -394,6 +396,8 @@ function getWidgets(event, roomId) { sendError(event, _t('This room is not recognised.')); return; } + // TODO - Room widgets need to be moved to 'm.widget' state events + // https://docs.google.com/document/d/1uPF7XWY_dXTKVKV7jZQ2KmsI19wn9-kFRgQ1tFQP7wQ/edit?usp=sharing const stateEvents = room.currentState.getStateEvents("im.vector.modular.widgets"); // Only return widgets which have required fields if (room) { diff --git a/src/WidgetUtils.js b/src/WidgetUtils.js index 34c998978d..5f45a8c58c 100644 --- a/src/WidgetUtils.js +++ b/src/WidgetUtils.js @@ -17,8 +17,8 @@ limitations under the License. import MatrixClientPeg from './MatrixClientPeg'; export default class WidgetUtils { - /* Returns true if user is able to send state events to modify widgets in this room + * (Does not apply to non-room-based / user widgets) * @param roomId -- The ID of the room to check * @return Boolean -- true if the user can modify widgets in this room * @throws Error -- specifies the error reason diff --git a/src/utils/widgets.js b/src/utils/widgets.js index 62f841c9c2..0d7f5dbf3f 100644 --- a/src/utils/widgets.js +++ b/src/utils/widgets.js @@ -64,6 +64,7 @@ function getStickerpickerWidgets() { /** * Remove all stickerpicker widgets (stickerpickers are user widgets by nature) + * @return {Promise} Resolves on account data updated */ function removeStickerpickerWidgets() { const client = MatrixClientPeg.get();