Support changing your integration manager in the UI

Part of https://github.com/vector-im/riot-web/issues/10161
This commit is contained in:
Travis Ralston 2019-08-12 15:35:39 -06:00
parent e21c12c2c9
commit 03d735f4ed
8 changed files with 289 additions and 4 deletions

View file

@ -351,6 +351,20 @@ export default class WidgetUtils {
return widgets.filter(w => w.content && imTypes.includes(w.content.type));
}
static removeIntegrationManagerWidgets() {
const client = MatrixClientPeg.get();
if (!client) {
throw new Error('User not logged in');
}
const userWidgets = client.getAccountData('m.widgets').getContent() || {};
Object.entries(userWidgets).forEach(([key, widget]) => {
if (widget.content && widget.content.type === 'm.integration_manager') {
delete userWidgets[key];
}
});
return client.setAccountData('m.widgets', userWidgets);
}
/**
* Remove all stickerpicker widgets (stickerpickers are user widgets by nature)
* @return {Promise} Resolves on account data updated