-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32094 from kubabutkiewicz/ts-migration/LocalNotif…
…ication-lib [TS migration] Migrate 'LocalNotification' lib to TypeScript
- Loading branch information
Showing
9 changed files
with
69 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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
5 changes: 4 additions & 1 deletion
5
...calNotification/focusApp/index.desktop.js → ...calNotification/focusApp/index.desktop.ts
This file contains 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,5 +1,8 @@ | ||
import ELECTRON_EVENTS from '../../../../../desktop/ELECTRON_EVENTS'; | ||
import FocusApp from './types'; | ||
|
||
export default () => { | ||
const focusApp: FocusApp = () => { | ||
window.electron.send(ELECTRON_EVENTS.REQUEST_FOCUS_APP); | ||
}; | ||
|
||
export default focusApp; |
This file contains 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 @@ | ||
import FocusApp from './types'; | ||
|
||
// On web this is up to the browser that shows the notifications | ||
const focusApp: FocusApp = () => {}; | ||
|
||
export default focusApp; |
2 changes: 0 additions & 2 deletions
2
src/libs/Notification/LocalNotification/focusApp/index.website.js
This file was deleted.
Oops, something went wrong.
This file contains 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 FocusApp = () => void; | ||
|
||
export default FocusApp; |
21 changes: 6 additions & 15 deletions
21
...cation/LocalNotification/index.desktop.js → ...cation/LocalNotification/index.desktop.ts
This file contains 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,31 +1,22 @@ | ||
import BrowserNotifications from './BrowserNotifications'; | ||
import {LocalNotificationModule, ReportCommentParams} from './types'; | ||
|
||
/** | ||
* @param {Object} options | ||
* @param {Object} options.report | ||
* @param {Object} options.reportAction | ||
* @param {Function} options.onClick | ||
*/ | ||
function showCommentNotification({report, reportAction, onClick}) { | ||
function showCommentNotification({report, reportAction, onClick}: ReportCommentParams) { | ||
BrowserNotifications.pushReportCommentNotification({report, reportAction, onClick}); | ||
} | ||
|
||
function showUpdateAvailableNotification() { | ||
BrowserNotifications.pushUpdateAvailableNotification(); | ||
} | ||
|
||
/** | ||
* @param {Object} options | ||
* @param {Object} options.report | ||
* @param {Object} options.reportAction | ||
* @param {Function} options.onClick | ||
*/ | ||
function showModifiedExpenseNotification({report, reportAction, onClick}) { | ||
function showModifiedExpenseNotification({report, reportAction, onClick}: ReportCommentParams) { | ||
BrowserNotifications.pushModifiedExpenseNotification({report, reportAction, onClick}); | ||
} | ||
|
||
export default { | ||
const LocalNotification: LocalNotificationModule = { | ||
showCommentNotification, | ||
showUpdateAvailableNotification, | ||
showModifiedExpenseNotification, | ||
}; | ||
|
||
export default LocalNotification; |
6 changes: 5 additions & 1 deletion
6
...ication/LocalNotification/index.native.js → ...ication/LocalNotification/index.native.ts
This file contains 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,6 +1,10 @@ | ||
import {LocalNotificationModule} from './types'; | ||
|
||
// Local Notifications are not currently supported on mobile so we'll just noop here. | ||
export default { | ||
const LocalNotification: LocalNotificationModule = { | ||
showCommentNotification: () => {}, | ||
showUpdateAvailableNotification: () => {}, | ||
showModifiedExpenseNotification: () => {}, | ||
}; | ||
|
||
export default LocalNotification; |
21 changes: 6 additions & 15 deletions
21
...cation/LocalNotification/index.website.js → ...s/Notification/LocalNotification/index.ts
This file contains 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,31 +1,22 @@ | ||
import BrowserNotifications from './BrowserNotifications'; | ||
import {LocalNotificationModule, ReportCommentParams} from './types'; | ||
|
||
/** | ||
* @param {Object} options | ||
* @param {Object} options.report | ||
* @param {Object} options.reportAction | ||
* @param {Function} options.onClick | ||
*/ | ||
function showCommentNotification({report, reportAction, onClick}) { | ||
function showCommentNotification({report, reportAction, onClick}: ReportCommentParams) { | ||
BrowserNotifications.pushReportCommentNotification({report, reportAction, onClick}, true); | ||
} | ||
|
||
function showUpdateAvailableNotification() { | ||
BrowserNotifications.pushUpdateAvailableNotification(); | ||
} | ||
|
||
/** | ||
* @param {Object} options | ||
* @param {Object} options.report | ||
* @param {Object} options.reportAction | ||
* @param {Function} options.onClick | ||
*/ | ||
function showModifiedExpenseNotification({report, reportAction, onClick}) { | ||
function showModifiedExpenseNotification({report, reportAction, onClick}: ReportCommentParams) { | ||
BrowserNotifications.pushModifiedExpenseNotification({report, reportAction, onClick}, true); | ||
} | ||
|
||
export default { | ||
const LocalNotification: LocalNotificationModule = { | ||
showCommentNotification, | ||
showUpdateAvailableNotification, | ||
showModifiedExpenseNotification, | ||
}; | ||
|
||
export default LocalNotification; |
This file contains 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,25 @@ | ||
import {ImageSourcePropType} from 'react-native'; | ||
import {Report, ReportAction} from '@src/types/onyx'; | ||
|
||
type PushParams = { | ||
title: string; | ||
body?: string; | ||
icon?: string | ImageSourcePropType; | ||
delay?: number; | ||
onClick?: () => void; | ||
tag?: string; | ||
}; | ||
|
||
type ReportCommentParams = { | ||
report: Report; | ||
reportAction: ReportAction; | ||
onClick: () => void; | ||
}; | ||
|
||
type LocalNotificationModule = { | ||
showCommentNotification: (reportCommentParams: ReportCommentParams) => void; | ||
showUpdateAvailableNotification: () => void; | ||
showModifiedExpenseNotification: (reportCommentParams: ReportCommentParams) => void; | ||
}; | ||
|
||
export type {PushParams, ReportCommentParams, LocalNotificationModule}; |