From f3943bef51e9551634b42ffad6daef72fc9879c8 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Wed, 7 Feb 2018 10:05:50 +0000 Subject: [PATCH] Check for empty user widgets. --- src/components/views/rooms/Stickerpack.js | 1 - src/utils/widgets.js | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/Stickerpack.js b/src/components/views/rooms/Stickerpack.js index a61ca84fbd..3722818bf6 100644 --- a/src/components/views/rooms/Stickerpack.js +++ b/src/components/views/rooms/Stickerpack.js @@ -87,7 +87,6 @@ export default class Stickerpack extends React.Component { this._getStickerPickerWidget(); return; } - console.error("Unhandled widget action"); } _getStickerPickerWidget() { diff --git a/src/utils/widgets.js b/src/utils/widgets.js index 081815fed9..2c7901a18f 100644 --- a/src/utils/widgets.js +++ b/src/utils/widgets.js @@ -36,8 +36,12 @@ function getUserWidgets() { if (!client) { throw new Error('User not logged in'); } - const userWidgets = client.getAccountData('m.widgets').getContent() || {}; - return Object.keys(userWidgets).map((key) => userWidgets[key]); + const userWidgets = client.getAccountData('m.widgets'); + let userWidgetContent = {}; + if (userWidgets && userWidgets.getContent()) { + userWidgetContent = userWidgets.getContent(); + } + return Object.keys(userWidgetContent).map((key) => userWidgetContent[key]); } /**