Fix badge not cleared on app launch

This commit is contained in:
Zhiyuan Zheng 2022-06-06 12:42:38 +02:00
parent 84deb2ba58
commit b18ccc5490
2 changed files with 2 additions and 2 deletions

View File

@ -4,7 +4,7 @@
"native": "220508", "native": "220508",
"major": 4, "major": 4,
"minor": 0, "minor": 0,
"patch": 4, "patch": 5,
"expo": "45.0.0" "expo": "45.0.0"
}, },
"description": "tooot app for Mastodon", "description": "tooot app for Mastodon",

View File

@ -78,7 +78,6 @@ const pushUseConnect = ({ t, instances }: Params) => {
useEffect(() => { useEffect(() => {
const appStateListener = AppState.addEventListener('change', state => { const appStateListener = AppState.addEventListener('change', state => {
console.log('changing state to', state)
if (expoToken && pushEnabled.length && state === 'active') { if (expoToken && pushEnabled.length && state === 'active') {
Notifications.getBadgeCountAsync().then(count => { Notifications.getBadgeCountAsync().then(count => {
if (count > 0) { if (count > 0) {
@ -96,6 +95,7 @@ const pushUseConnect = ({ t, instances }: Params) => {
return useEffect(() => { return useEffect(() => {
if (expoToken && pushEnabled.length) { if (expoToken && pushEnabled.length) {
Notifications.setBadgeCountAsync(0)
connect() connect()
} }
}, [expoToken, pushEnabled.length]) }, [expoToken, pushEnabled.length])