Browse Source

small AppState fix

Viktoriia 4 tháng trước cách đây
mục cha
commit
5ab78eea46

+ 6 - 1
src/screens/InAppScreens/MessagesScreen/ChatScreen/index.tsx

@@ -608,7 +608,12 @@ const ChatScreen = ({ route }: { route: any }) => {
 
   useEffect(() => {
     const handleAppStateChange = async (nextAppState: AppStateStatus) => {
-      if (appState.current.match(/inactive|background/) && nextAppState === 'active') {
+      const prevState = appState.current;
+      appState.current = nextAppState;
+
+      if (prevState.match(/inactive|background/) && nextAppState === 'active') {
+        refetch();
+
         if (!socket.current || socket.current.readyState === WebSocket.CLOSED) {
           socket.current = new WebSocket(WEBSOCKET_URL);
           socket.current.onopen = () => {

+ 6 - 1
src/screens/InAppScreens/MessagesScreen/GroupChatScreen/index.tsx

@@ -614,7 +614,12 @@ const GroupChatScreen = ({ route }: { route: any }) => {
 
   useEffect(() => {
     const handleAppStateChange = async (nextAppState: AppStateStatus) => {
-      if (appState.current.match(/inactive|background/) && nextAppState === 'active') {
+      const prevState = appState.current;
+      appState.current = nextAppState;
+
+      if (prevState.match(/inactive|background/) && nextAppState === 'active') {
+        refetch();
+
         if (!socket.current || socket.current.readyState === WebSocket.CLOSED) {
           socket.current = new WebSocket(WEBSOCKET_URL);
           socket.current.onopen = () => {