From dc9d80d2a84927119381eeee1b16e10099f08334 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 24 May 2024 19:59:28 +0100 Subject: [🐴] update convo list from message bus (#4189) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- src/lib/hooks/useAppState.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/lib/hooks/useAppState.ts (limited to 'src/lib/hooks/useAppState.ts') 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 +} -- cgit 1.4.1