-
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 #31762 from Expensify/arosiclair-clear-read-notifi…
…cations Clear notifications after opening a report
- Loading branch information
Showing
22 changed files
with
253 additions
and
129 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
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.