Repository navigation
[TS migration] Migrate 'PushNotification' lib to TypeScript #32180
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
da25fc5
Rename files to TS
fabioh8010 fe71069
Migrate ForegroundNotifications to TS
fabioh8010 0b0f19c
Migrate NotificationType and shouldShowPushNotification to TS
fabioh8010 7f2cd37
Merge branch 'main' into ts/lib/PushNotification
fabioh8010 31af9de
Minor fixes in backgroundRefresh
fabioh8010 7067417
make ForegroundNotifications capitalized
fabioh8010 c8f48ad
Several improvements and PushNotification migration
fabioh8010 8d98919
Minor improvements
fabioh8010 a7085cc
Merge branch 'main' into ts/lib/PushNotification
fabioh8010 8d9e2a9
Fix PushNotification register() promise bug
fabioh8010 72ee224
Mark some report comment notification data params as required
fabioh8010 3db74c0
Rename ForegroundNotificationsType to ForegroundNotificationsModule
fabioh8010 92559e1
Fix tests
fabioh8010 9976663
Merge branch 'main' into ts/lib/PushNotification
fabioh8010 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
...fication/ForegroundNotifications/index.js → ...fication/ForegroundNotifications/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| import ForegroundNotificationsModule from './types'; | ||
|
|
||
| /** | ||
| * Configures notification handling while in the foreground on iOS and Android. This is a no-op on other platforms. | ||
| */ | ||
| export default { | ||
| const ForegroundNotifications: ForegroundNotificationsModule = { | ||
| configureForegroundNotifications: () => {}, | ||
| disableForegroundNotifications: () => {}, | ||
| }; | ||
|
|
||
| export default ForegroundNotifications; |
6 changes: 6 additions & 0 deletions
6
src/libs/Notification/PushNotification/ForegroundNotifications/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| type ForegroundNotificationsModule = { | ||
| configureForegroundNotifications: () => void; | ||
| disableForegroundNotifications: () => void; | ||
| }; | ||
|
|
||
| export default ForegroundNotificationsModule; |
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/libs/Notification/PushNotification/NotificationType.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import {OnyxServerUpdate} from '@src/types/onyx/OnyxUpdatesFromServer'; | ||
|
|
||
| const NotificationType = { | ||
| REPORT_COMMENT: 'reportComment', | ||
| } as const; | ||
|
|
||
| type NotificationDataMap = { | ||
| [NotificationType.REPORT_COMMENT]: ReportCommentNotificationData; | ||
| }; | ||
|
|
||
| type NotificationData = ReportCommentNotificationData; | ||
|
|
||
| type ReportCommentNotificationData = { | ||
| title: string; | ||
| type: typeof NotificationType.REPORT_COMMENT; | ||
| reportID: number; | ||
| reportActionID: string; | ||
| shouldScrollToLastUnread?: boolean; | ||
| roomName?: string; | ||
| onyxData?: OnyxServerUpdate[]; | ||
| }; | ||
|
|
||
| /** | ||
| * See https://github.com/Expensify/Web-Expensify/blob/main/lib/MobilePushNotifications.php for the various | ||
| * types of push notifications sent by our API. | ||
| */ | ||
| export default NotificationType; | ||
| export type {NotificationDataMap, NotificationData, ReportCommentNotificationData}; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
...shNotification/backgroundRefresh/index.js → ...shNotification/backgroundRefresh/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| import BackgroundRefresh from './types'; | ||
|
|
||
| /** | ||
| * Runs our reconnectApp action if the app is in the background. | ||
| * | ||
| * We use this to refresh the app in the background after receiving a push notification (native only). Since the full app | ||
| * wakes on iOS and by extension runs reconnectApp already, this is a no-op on everything but Android. | ||
| */ | ||
| export default function backgroundRefresh() {} | ||
| const backgroundRefresh: BackgroundRefresh = () => {}; | ||
|
|
||
| export default backgroundRefresh; |
3 changes: 3 additions & 0 deletions
3
src/libs/Notification/PushNotification/backgroundRefresh/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| type BackgroundRefresh = () => void; | ||
|
|
||
| export default BackgroundRefresh; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.