mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-04 13:15:58 +03:00
Add method to remove all stickerpacks.
This commit is contained in:
parent
29962ed89d
commit
34de3729fe
1 changed files with 22 additions and 1 deletions
|
@ -45,12 +45,33 @@ function getUserWidgets() {
|
|||
* @return {[object]} Array containing current / active stickerpack widgets
|
||||
*/
|
||||
function getStickerpackWidgets() {
|
||||
return getUserWidgets().filter((widget) => widget.type='stickerpack');
|
||||
const stickerpackWidgets = getUserWidgets().filter((widget) => widget.type='stickerpack');
|
||||
console.warn('Stickerpack widgets', stickerpackWidgets);
|
||||
return stickerpackWidgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all stickerpack widgets (stickerpacks are user widgets by nature)
|
||||
*/
|
||||
function removeStickerpackWidgets() {
|
||||
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.type === 'stickerpack') {
|
||||
delete userWidgets[key];
|
||||
}
|
||||
});
|
||||
client.setAccountData('m.widgets', userWidgets);
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
getWidgets,
|
||||
getRoomWidgets,
|
||||
getUserWidgets,
|
||||
getStickerpackWidgets,
|
||||
removeStickerpackWidgets,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue