mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 12:28:50 +03:00
No-op removals of widgets that don't exist
An example of this is setting your very first widget: there's nothing to remove, so you end up with "cannot call .getContent() of undefined" instead.
This commit is contained in:
parent
04bb2ed322
commit
19b7d18e7a
1 changed files with 6 additions and 2 deletions
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue