-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Clear notifications after opening a report #31762
Merged
Merged
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
3c5c0fa
cache notifications so they can be cleared later
arosiclair f67a53f
replace unnecessary object params with regular params
arosiclair 43667cb
remove unused delay functionality
arosiclair dfd1246
replace object params with regular params
arosiclair 6f432cf
remove unused promise
arosiclair 3156398
add reportID to notification data
arosiclair 78cadff
clear local notifications when opening a report
arosiclair 9d8d1f7
fix data for modified expense notification
arosiclair 3ef347c
use onclose to clear the cache
arosiclair e4ca268
use empty object by default for safety
arosiclair 1f0b1a0
improve docs for LocalNotification lib
arosiclair ed5e3a1
clear local notifications when the window is focused
arosiclair 041354f
prevent background ReportScreens from clearing notifications
arosiclair 8d442eb
undo name change to avoid new JS lib error
arosiclair 99a6df1
prettier
arosiclair e41144f
clarifying comments
arosiclair 0f5bd2e
rename prevNotificationID to notificationID
arosiclair 0bd4077
Merge branch 'arosiclair-clear-read-notifications' into arosiclair-cl…
arosiclair ea5f257
Merge branch 'main' of github.com:Expensify/App into arosiclair-clear…
arosiclair 6edd1d9
add android native module for clearing notifications
arosiclair 8586346
Merge branch 'main' of github.com:Expensify/App into arosiclair-clear…
arosiclair e5923f2
add clearReportNotifications lib and use airship APIs on native
arosiclair 03e0b52
remove unnecessary native lib
arosiclair 88d388a
Revert "rename prevNotificationID to notificationID"
arosiclair 81737f1
Merge branch 'main' of github.com:Expensify/App into arosiclair-clear…
arosiclair 872c430
param fixes
arosiclair d8b3479
convert to typescript
arosiclair a25b7a7
use common types module and default to web implementation
arosiclair 4657139
correctly parse the notification and report IDs
arosiclair 8de5ed2
delete accidental jsbundle
arosiclair d917b93
Merge branch 'main' of github.com:Expensify/App into arosiclair-clear…
arosiclair 84e563e
use new NotificationData type
arosiclair 302c394
mock getActiveNotifications to fix tests
arosiclair af158c5
remove useless jsdoc
arosiclair 8e27363
prettier
arosiclair b420620
simplify clearNotifications
arosiclair 4e8f316
use AppState on native
arosiclair e4e342e
rename to useAppFocusEvent
arosiclair 05a19de
use airship v15.3.1 patch
arosiclair afa8e4a
Merge branch 'main' of github.com:Expensify/App into arosiclair-clear…
arosiclair 8776f36
use release airship 15.3.1 version
arosiclair 9b5f2dc
actually use the release version of 15.3.1
arosiclair 6dce2d2
update podfile and gemfile
arosiclair 9ebe227
catch and log unexpected errors
arosiclair 01e7905
Merge branch 'main' of github.com:Expensify/App into arosiclair-clear…
arosiclair 2cbaaef
Merge branch 'main' of github.com:Expensify/App into arosiclair-clear…
arosiclair dc7bac6
Merge branch 'main' of github.com:Expensify/App into arosiclair-clear…
arosiclair c6c3e98
remove inconsistent param validation
arosiclair 2f7707f
reduce number of array iterations
arosiclair a318f0f
move native implementation to PushNotification lib
arosiclair 7a6581c
ensure the app is visible before marking the report read
arosiclair be23d55
use unified type for ClearReportNotifications
arosiclair 84acbc0
Merge branch 'main' of github.com:Expensify/App into arosiclair-clear…
arosiclair dc3cc66
undo accidental change
arosiclair ede3435
set readActionSkipped only when report is unread
arosiclair 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 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,20 @@ | ||
import {useEffect} from 'react'; | ||
import {AppState} from 'react-native'; | ||
import {UseAppFocusEvent, UseAppFocusEventCallback} from './types'; | ||
|
||
const useAppFocusEvent: UseAppFocusEvent = (callback: UseAppFocusEventCallback) => { | ||
useEffect(() => { | ||
const subscription = AppState.addEventListener('change', (appState) => { | ||
if (appState !== 'active') { | ||
return; | ||
} | ||
callback(); | ||
}); | ||
|
||
return () => { | ||
subscription.remove(); | ||
}; | ||
}, [callback]); | ||
}; | ||
|
||
export default useAppFocusEvent; |
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,19 @@ | ||
import {useEffect} from 'react'; | ||
import {UseAppFocusEvent, UseAppFocusEventCallback} from './types'; | ||
|
||
/** | ||
* Runs the given callback when the app is focused (eg: after re-opening the app, switching tabs, or focusing the window) | ||
* | ||
* @param callback the function to run when the app is focused. This should be memoized with `useCallback`. | ||
*/ | ||
const useAppFocusEvent: UseAppFocusEvent = (callback: UseAppFocusEventCallback) => { | ||
useEffect(() => { | ||
window.addEventListener('focus', callback); | ||
|
||
return () => { | ||
window.removeEventListener('focus', callback); | ||
}; | ||
}, [callback]); | ||
}; | ||
|
||
export default useAppFocusEvent; |
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,5 @@ | ||
type UseAppFocusEventCallback = () => void; | ||
|
||
type UseAppFocusEvent = (callback: UseAppFocusEventCallback) => void; | ||
|
||
export type {UseAppFocusEventCallback, UseAppFocusEvent}; |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB. We don't need to supply a function as param. There is only one function, we can just keep passing the
reportID