From 210fcf0d52219f767896f242783becaffab9f329 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 13 May 2018 16:41:19 -0600 Subject: [PATCH] Correctly identify sticker picker widgets Widgets added to account data have the `type` of "m.widget", meaning we have to look at the `content.type` which will tell us what it is. This also fixes a bug where all user widgets become sticker picker widgets under the right conditions. Signed-off-by: Travis Ralston --- src/utils/widgets.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/widgets.js b/src/utils/widgets.js index 0d7f5dbf3f..338df184e2 100644 --- a/src/utils/widgets.js +++ b/src/utils/widgets.js @@ -58,8 +58,7 @@ function getUserWidgetsArray() { */ function getStickerpickerWidgets() { const widgets = getUserWidgetsArray(); - const stickerpickerWidgets = widgets.filter((widget) => widget.type='m.stickerpicker'); - return stickerpickerWidgets; + return widgets.filter((widget) => widget.content && widget.content.type === "m.stickerpicker"); } /** @@ -73,7 +72,7 @@ function removeStickerpickerWidgets() { } const userWidgets = client.getAccountData('m.widgets').getContent() || {}; Object.entries(userWidgets).forEach(([key, widget]) => { - if (widget.type === 'm.stickerpicker') { + if (widget.content && widget.content.type === 'm.stickerpicker') { delete userWidgets[key]; } });