diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-05-24 19:59:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-24 13:59:28 -0500 |
commit | dc9d80d2a84927119381eeee1b16e10099f08334 (patch) | |
tree | 85ac730ee863270a4b63be2d1a93c08541a7a71e /src/lib/hooks/useAppState.ts | |
parent | c0175af76a72ec270300d13db87e9617d9782bac (diff) | |
download | voidsky-dc9d80d2a84927119381eeee1b16e10099f08334.tar.zst |
[🐴] update convo list from message bus (#4189)
* update convo list from message bus * don't increase unread count if you're the sender * add refetch interval back * Fix deleted message state copy * only enable if `hasSession` * Fix logged out handling * increase refetch interval to 60s * request 10s interval when message screen active * use useAppState hook for convo resume/background * Combine forces * fix useFocusEffect logic --------- Co-authored-by: Eric Bailey <git@esb.lol>
Diffstat (limited to 'src/lib/hooks/useAppState.ts')
-rw-r--r-- | src/lib/hooks/useAppState.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/hooks/useAppState.ts b/src/lib/hooks/useAppState.ts new file mode 100644 index 000000000..7fb228d61 --- /dev/null +++ b/src/lib/hooks/useAppState.ts @@ -0,0 +1,15 @@ +import {useEffect, useState} from 'react' +import {AppState} from 'react-native' + +export function useAppState() { + const [state, setState] = useState(AppState.currentState) + + useEffect(() => { + const sub = AppState.addEventListener('change', nextAppState => { + setState(nextAppState) + }) + return () => sub.remove() + }, []) + + return state +} |