Merge pull request #3336 from matrix-org/travis/fix-removing-widgets

No-op removals of widgets that don't exist
This commit is contained in:
Travis Ralston 2019-08-22 08:34:11 -06:00 committed by GitHub
commit e9b44c9802
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -354,7 +354,9 @@ export default class WidgetUtils {
if (!client) {
throw new Error('User not logged in');
}
const userWidgets = client.getAccountData('m.widgets').getContent() || {};
const widgets = client.getAccountData('m.widgets');
if (!widgets) return;
const userWidgets = widgets.getContent() || {};
Object.entries(userWidgets).forEach(([key, widget]) => {
if (widget.content && widget.content.type === "m.integration_manager") {
delete userWidgets[key];
@ -382,7 +384,9 @@ export default class WidgetUtils {
if (!client) {
throw new Error('User not logged in');
}
const userWidgets = client.getAccountData('m.widgets').getContent() || {};
const widgets = client.getAccountData('m.widgets');
if (!widgets) return;
const userWidgets = widgets.getContent() || {};
Object.entries(userWidgets).forEach(([key, widget]) => {
if (widget.content && widget.content.type === 'm.stickerpicker') {
delete userWidgets[key];