Skip to content

Commit

Permalink
export NotificationController and fix types (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeRx authored May 3, 2022
1 parent 654e5dc commit 0b6e5a0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export * from './assets/CollectibleDetectionController';
export * from './permissions';
export * from './subject-metadata';
export * from './ratelimit/RateLimitController';
export * from './notification/NotificationController';
export { util };
4 changes: 2 additions & 2 deletions src/notification/NotificationController.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ControllerMessenger } from '../ControllerMessenger';
import {
ControllerActions,
NotificationControllerActions,
NotificationController,
NotificationControllerStateChange,
} from './NotificationController';
Expand All @@ -14,7 +14,7 @@ const name = 'NotificationController';
*/
function getUnrestrictedMessenger() {
return new ControllerMessenger<
ControllerActions,
NotificationControllerActions,
NotificationControllerStateChange
>();
}
Expand Down
4 changes: 2 additions & 2 deletions src/notification/NotificationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ export type MarkNotificationRead = {
handler: NotificationController['markRead'];
};

export type ControllerActions =
export type NotificationControllerActions =
| GetNotificationControllerState
| ShowNotification
| DismissNotification
| MarkNotificationRead;

export type NotificationControllerMessenger = RestrictedControllerMessenger<
typeof name,
ControllerActions,
NotificationControllerActions,
NotificationControllerStateChange,
never,
never
Expand Down
4 changes: 2 additions & 2 deletions src/ratelimit/RateLimitController.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ControllerMessenger } from '../ControllerMessenger';
import {
ControllerActions,
RateLimitControllerActions,
RateLimitStateChange,
RateLimitController,
RateLimitMessenger,
Expand Down Expand Up @@ -39,7 +39,7 @@ function getRestrictedMessenger(
) {
return controllerMessenger.getRestricted<
typeof name,
ControllerActions<RateLimitedApis>['type'],
RateLimitControllerActions<RateLimitedApis>['type'],
never
>({
name,
Expand Down
4 changes: 2 additions & 2 deletions src/ratelimit/RateLimitController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ export type CallApi<
handler: RateLimitController<RateLimitedApis>['call'];
};

export type ControllerActions<
export type RateLimitControllerActions<
RateLimitedApis extends Record<string, (...args: any[]) => any>,
> = GetRateLimitState<RateLimitedApis> | CallApi<RateLimitedApis>;

export type RateLimitMessenger<
RateLimitedApis extends Record<string, (...args: any[]) => any>,
> = RestrictedControllerMessenger<
typeof name,
ControllerActions<RateLimitedApis>,
RateLimitControllerActions<RateLimitedApis>,
RateLimitStateChange<RateLimitedApis>,
never,
never
Expand Down

0 comments on commit 0b6e5a0

Please sign in to comment.