diff --git a/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.test.ts b/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.test.ts index 2e3da824191..13745c925b7 100644 --- a/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.test.ts +++ b/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.test.ts @@ -41,6 +41,7 @@ import { processFeatureAnnouncement } from './processors'; import { processNotification } from './processors/process-notifications'; import { processSnapNotification } from './processors/process-snap-notifications'; import * as OnChainNotifications from './services/onchain-notifications'; +import type { INotification } from './types'; import type { UserStorage } from './types/user-storage/user-storage'; import * as Utils from './utils/utils'; @@ -834,7 +835,13 @@ describe('metamask-notifications - disableMetamaskNotifications()', () => { const controller = new NotificationServicesController({ messenger: mocks.messenger, env: { featureAnnouncements: featureAnnouncementsEnv }, - state: { isNotificationServicesEnabled: true }, + state: { + isNotificationServicesEnabled: true, + metamaskNotificationsList: [ + createMockFeatureAnnouncementRaw() as INotification, + createMockSnapNotification() as INotification, + ], + }, }); const promise = controller.disableNotificationServices(); @@ -847,6 +854,9 @@ describe('metamask-notifications - disableMetamaskNotifications()', () => { // Act - final state expect(controller.state.isUpdatingMetamaskNotifications).toBe(false); expect(controller.state.isNotificationServicesEnabled).toBe(false); + expect(controller.state.metamaskNotificationsList).toStrictEqual([ + createMockSnapNotification(), + ]); expect(mocks.mockDisablePushNotifications).toHaveBeenCalled(); diff --git a/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.ts b/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.ts index 5a8d204e4a9..1421b6cf690 100644 --- a/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.ts +++ b/packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.ts @@ -924,11 +924,17 @@ export default class NotificationServicesController extends BaseController< const UUIDs = Utils.getAllUUIDs(userStorage); await this.#pushNotifications.disablePushNotifications(UUIDs); + const snapNotifications = this.state.metamaskNotificationsList.filter( + (notification) => notification.type === TRIGGER_TYPES.SNAP, + ); + // Clear Notification States (toggles and list) this.update((state) => { state.isNotificationServicesEnabled = false; state.isFeatureAnnouncementsEnabled = false; - state.metamaskNotificationsList = []; + // reassigning the notifications list with just snaps + // since the disable shouldn't affect snaps notifications + state.metamaskNotificationsList = snapNotifications; }); } catch (e) { log.error('Unable to disable notifications', e);