Fix user widget event type.

Add comments for clarity.
This commit is contained in:
Richard Lewis 2018-04-02 10:02:41 +01:00
parent 557a45e890
commit 11915b0cdf
3 changed files with 7 additions and 2 deletions

View file

@ -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) {

View file

@ -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

View file

@ -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();