Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 210fcf0

Browse files
committed
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 <[email protected]>
1 parent f8fd90c commit 210fcf0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/utils/widgets.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ function getUserWidgetsArray() {
5858
*/
5959
function getStickerpickerWidgets() {
6060
const widgets = getUserWidgetsArray();
61-
const stickerpickerWidgets = widgets.filter((widget) => widget.type='m.stickerpicker');
62-
return stickerpickerWidgets;
61+
return widgets.filter((widget) => widget.content && widget.content.type === "m.stickerpicker");
6362
}
6463

6564
/**
@@ -73,7 +72,7 @@ function removeStickerpickerWidgets() {
7372
}
7473
const userWidgets = client.getAccountData('m.widgets').getContent() || {};
7574
Object.entries(userWidgets).forEach(([key, widget]) => {
76-
if (widget.type === 'm.stickerpicker') {
75+
if (widget.content && widget.content.type === 'm.stickerpicker') {
7776
delete userWidgets[key];
7877
}
7978
});

0 commit comments

Comments
 (0)