Skip to content

Commit 2ee8a9f

Browse files
refactor: Remove unused notification code (#22833)
<!-- 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** Removes `useRegisterPushNotificationsEffect` and related unused code, including: - `hasInitialNotification` from `app/util/notifications/methods/common.ts` - `getInitialNotification` and `onBackgroundEvent` from `app/util/notifications/services/NotificationService.ts` - `useRegisterPushNotificationsEffect.ts` and its test file - The usage of `useRegisterPushNotificationsEffect` in `useNotificationHandler` <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-1552 ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **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** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] 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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Removes useRegisterPushNotificationsEffect and initial/background notification handlers/utilities, updating hooks, tests, and NotificationService accordingly. > > - **Notifications hooks**: > - Remove `useRegisterPushNotificationsEffect` and its test file. > - Stop invoking it in `hooks/index.ts`; only call `useStartupNotificationsEffect`. > - Update `hooks/index.test.tsx` to assert only `useStartupNotificationsEffect` is invoked. > - **NotificationService (`services/NotificationService.ts`)**: > - Remove `getInitialNotification` and `onBackgroundEvent` wrappers and related imports/types. > - Keep `onForegroundEvent`, badge count helpers, and display flow intact. > - **Methods (`methods/common.ts`)**: > - Remove `notifee` import and `hasInitialNotification` helper. > - Retain `withTimeout` and other utilities unchanged. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7b1c858. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 76ef8e6 commit 2ee8a9f

File tree

6 files changed

+1
-409
lines changed

6 files changed

+1
-409
lines changed

app/util/notifications/hooks/index.test.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { NavigationContainerRef } from '@react-navigation/native';
22
import { renderHook } from '@testing-library/react-hooks';
33
import useNotificationHandler from './index';
44
// eslint-disable-next-line import/no-namespace
5-
import * as UseRegisterPushNotificationsEffect from './useRegisterPushNotificationsEffect';
6-
// eslint-disable-next-line import/no-namespace
75
import * as UseNotifications from './useStartupNotificationsEffect';
86

97
describe('useNotificationHandler', () => {
@@ -17,20 +15,12 @@ describe('useNotificationHandler', () => {
1715
navigate: mockNavigate,
1816
} as unknown as NavigationContainerRef;
1917

20-
const mockUseRegisterPushNotificationsEffect = jest
21-
.spyOn(
22-
UseRegisterPushNotificationsEffect,
23-
'useRegisterPushNotificationsEffect',
24-
)
25-
.mockImplementation(jest.fn());
26-
2718
const mockUseListNotificationsEffect = jest
2819
.spyOn(UseNotifications, 'useStartupNotificationsEffect')
2920
.mockImplementation(jest.fn());
3021

3122
return {
3223
mockNavigation,
33-
mockUseRegisterPushNotificationsEffect,
3424
mockUseListNotificationsEffect,
3525
};
3626
};
@@ -39,7 +29,6 @@ describe('useNotificationHandler', () => {
3929
const mocks = arrangeMocks();
4030
renderHook(() => useNotificationHandler());
4131

42-
expect(mocks.mockUseRegisterPushNotificationsEffect).toHaveBeenCalled();
4332
expect(mocks.mockUseListNotificationsEffect).toHaveBeenCalled();
4433
});
4534
});

app/util/notifications/hooks/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { useRegisterPushNotificationsEffect } from './useRegisterPushNotificationsEffect';
21
import { useStartupNotificationsEffect } from './useStartupNotificationsEffect';
32

43
/**
5-
* Registers Push Notifications and lists notifications on startup.
4+
* Lists notifications on startup.
65
*/
76
const useNotificationHandler = () => {
8-
useRegisterPushNotificationsEffect();
97
useStartupNotificationsEffect();
108
};
119

app/util/notifications/hooks/useRegisterPushNotificationsEffect.test.ts

Lines changed: 0 additions & 231 deletions
This file was deleted.

0 commit comments

Comments
 (0)