-
-
Notifications
You must be signed in to change notification settings - Fork 245
refactor: migrate {NotificationServices,NotificationServicesPush}Controller
to `@metamask/messenger
#6538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
refactor: migrate {NotificationServices,NotificationServicesPush}Controller
to `@metamask/messenger
#6538
Conversation
9449e6e
to
851b86f
Compare
…roller to @metamask/messenger
851b86f
to
e948005
Compare
isFeatureAnnouncementsEnabled: true, | ||
isNotificationServicesEnabled: true, | ||
}, | ||
describe('NotificationServicesController', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we reformat the tests in another PR? Otherwise this diff is somewhat difficult to read.
const globalMessenger = getRootMessenger(); | ||
|
||
return globalMessenger.getRestricted< | ||
'NotificationServicesPushController', | ||
AllowedActions['type'] | ||
const messenger = new Messenger< | ||
typeof controllerName, | ||
AllNotificationServicesPushControllerActions, | ||
AllNotificationServicesPushControllerEvents, | ||
RootMessenger | ||
>({ | ||
name: 'NotificationServicesPushController', | ||
allowedActions: ['AuthenticationController:getBearerToken'], | ||
allowedEvents: [], | ||
namespace: controllerName, | ||
parent: globalMessenger, | ||
}); | ||
|
||
globalMessenger.delegate({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Should we rename this variable to rootMessenger
?
const globalMessenger = getRootMessenger(); | |
return globalMessenger.getRestricted< | |
'NotificationServicesPushController', | |
AllowedActions['type'] | |
const messenger = new Messenger< | |
typeof controllerName, | |
AllNotificationServicesPushControllerActions, | |
AllNotificationServicesPushControllerEvents, | |
RootMessenger | |
>({ | |
name: 'NotificationServicesPushController', | |
allowedActions: ['AuthenticationController:getBearerToken'], | |
allowedEvents: [], | |
namespace: controllerName, | |
parent: globalMessenger, | |
}); | |
globalMessenger.delegate({ | |
const rootMessenger = getRootMessenger(); | |
const messenger = new Messenger< | |
typeof controllerName, | |
AllNotificationServicesPushControllerActions, | |
AllNotificationServicesPushControllerEvents, | |
RootMessenger | |
>({ | |
namespace: controllerName, | |
parent: rootMessenger, | |
}); | |
rootMessenger.delegate({ |
@@ -195,7 +195,7 @@ export type Actions = | |||
| NotificationServicesControllerDeleteNotificationsById; | |||
|
|||
// Allowed Actions | |||
export type AllowedActions = | |||
type AllowedActions = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because @metamask/notification-services-controller
is using barrel exports in index.ts
, I believe that if we don't export this type it will remove the export from the whole package, can you confirm? If so should we add this to the changelog?
@@ -231,7 +231,7 @@ export type Events = | |||
| MarkNotificationsAsReadEvent; | |||
|
|||
// Allowed Events | |||
export type AllowedEvents = | |||
type AllowedEvents = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar as for AllowedActions
.
@@ -55,7 +55,7 @@ export type Actions = | |||
| NotificationServicesPushControllerUpdateTriggerPushNotificationsAction | |||
| NotificationServicesPushControllerSubscribeToNotificationsAction; | |||
|
|||
export type AllowedActions = | |||
type AllowedActions = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment as for NotificationServicesController.ts
.
@@ -79,14 +79,10 @@ export type Events = | |||
| NotificationServicesPushControllerOnNewNotificationEvent | |||
| NotificationServicesPushControllerPushNotificationClickedEvent; | |||
|
|||
export type AllowedEvents = never; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment as for NotificationServicesController.ts
.
Explanation
This PR migrates
NotificationServicesController
andNotificationServicesPushController
to the new@metamask/messenger
message bus, as opposed to the one exported from@metamask/base-controller
.References
Checklist