1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

remove snap notifications when uninstalled (#17487)

This commit is contained in:
Guillaume Roux 2023-01-30 13:43:47 +01:00 committed by GitHub
parent 245c32a99e
commit 82f2ba15e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1563,6 +1563,22 @@ export default class MetamaskController extends EventEmitter {
},
);
this.controllerMessenger.subscribe(
`${this.snapController.name}:snapRemoved`,
(truncatedSnap) => {
const notificationIds = Object.values(
this.notificationController.state.notifications,
).reduce((idList, notification) => {
if (notification.origin === truncatedSnap.id) {
idList.push(notification.id);
}
return idList;
}, []);
this.dismissNotifications(notificationIds);
},
);
///: END:ONLY_INCLUDE_IN
}