Skip to content

Commit

Permalink
chore: refactor methods/add FCM Services 3/3 (#12077)
Browse files Browse the repository at this point in the history
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

This is a 3/3 PRs to implement Firebase service into MetaMask. This
needs to merged sequentially following:

[12028](#12028)
[12045](#12045)

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
Jonathansoufer authored Nov 6, 2024
1 parent 91757b0 commit 323c319
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 204 deletions.
8 changes: 4 additions & 4 deletions app/selectors/notifications/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSelector } from 'reselect';

import { TRIGGER_TYPES } from '../../util/notifications';
import { TRIGGER_TYPES, Notification } from '../../util/notifications';

import { createDeepEqualSelector } from '../util';
import { RootState } from '../../reducers';
Expand Down Expand Up @@ -99,22 +99,22 @@ export const getMetamaskNotificationsUnreadCount = createSelector(
(notificationServicesControllerState: NotificationServicesState) =>
(
notificationServicesControllerState.metamaskNotificationsList ?? []
).filter((notification) => !notification.isRead).length,
).filter((notification: Notification) => !notification.isRead).length,
);
export const getMetamaskNotificationsReadCount = createSelector(
selectNotificationServicesControllerState,
(notificationServicesControllerState: NotificationServicesState) =>
(
notificationServicesControllerState.metamaskNotificationsList ?? []
).filter((notification) => notification.isRead).length,
).filter((notification: Notification) => notification.isRead).length,
);
export const getOnChainMetamaskNotificationsUnreadCount = createSelector(
selectNotificationServicesControllerState,
(notificationServicesControllerState: NotificationServicesState) =>
(
notificationServicesControllerState.metamaskNotificationsList ?? []
).filter(
(notification) =>
(notification: Notification) =>
!notification.isRead &&
notification.type !== TRIGGER_TYPES.FEATURES_ANNOUNCEMENT,
).length,
Expand Down
12 changes: 6 additions & 6 deletions app/util/notifications/androidChannels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ describe('notificationChannels', () => {
expect(firstChannel).toEqual({
id: ChannelId.DEFAULT_NOTIFICATION_CHANNEL_ID,
name: 'Transaction Complete',
lights: false,
vibration: false,
importance: AndroidImportance.DEFAULT,
lights: true,
vibration: true,
importance: AndroidImportance.HIGH,
title: 'Transaction',
subtitle: 'Transaction Complete',
});
Expand All @@ -28,9 +28,9 @@ describe('notificationChannels', () => {
expect(secondChannel).toEqual({
id: ChannelId.ANNOUNCEMENT_NOTIFICATION_CHANNEL_ID,
name: 'MetaMask Announcement',
lights: false,
vibration: false,
importance: AndroidImportance.DEFAULT,
lights: true,
vibration: true,
importance: AndroidImportance.HIGH,
title: 'Announcement',
subtitle: 'MetaMask Announcement',
});
Expand Down
12 changes: 6 additions & 6 deletions app/util/notifications/androidChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ export const notificationChannels = [
{
id: ChannelId.DEFAULT_NOTIFICATION_CHANNEL_ID,
name: 'Transaction Complete',
lights: false,
vibration: false,
importance: AndroidImportance.DEFAULT,
lights: true,
vibration: true,
importance: AndroidImportance.HIGH,
title: 'Transaction',
subtitle: 'Transaction Complete',
} as MetaMaskAndroidChannel,
{
id: ChannelId.ANNOUNCEMENT_NOTIFICATION_CHANNEL_ID,
name: 'MetaMask Announcement',
lights: false,
vibration: false,
importance: AndroidImportance.DEFAULT,
lights: true,
vibration: true,
importance: AndroidImportance.HIGH,
title: 'Announcement',
subtitle: 'MetaMask Announcement',
} as MetaMaskAndroidChannel,
Expand Down
2 changes: 2 additions & 0 deletions app/util/notifications/methods/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ describe('formatMenuItemDate', () => {
});
});
});


83 changes: 0 additions & 83 deletions app/util/notifications/methods/fcmHelper.test.ts

This file was deleted.

99 changes: 0 additions & 99 deletions app/util/notifications/methods/fcmHelper.ts

This file was deleted.

1 change: 0 additions & 1 deletion app/util/notifications/methods/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './fcmHelper';
export * from './common';
Loading

0 comments on commit 323c319

Please sign in to comment.