浏览代码

chat fixes

Viktoriia 9 月之前
父节点
当前提交
1190336bc4

+ 4 - 0
Route.tsx

@@ -424,6 +424,10 @@ const Route = () => {
               component={ProfileScreen}
               component={ProfileScreen}
             />
             />
             <ScreenStack.Screen name={NAVIGATION_PAGES.USERS_MAP} component={UsersMapScreen} />
             <ScreenStack.Screen name={NAVIGATION_PAGES.USERS_MAP} component={UsersMapScreen} />
+            <ScreenStack.Screen
+              name={NAVIGATION_PAGES.NOTIFICATIONS}
+              component={NotificationsScreen}
+            />
           </ScreenStack.Navigator>
           </ScreenStack.Navigator>
         )}
         )}
       </BottomTab.Screen>
       </BottomTab.Screen>

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

@@ -12,7 +12,8 @@ import {
   Linking,
   Linking,
   ActivityIndicator,
   ActivityIndicator,
   AppState,
   AppState,
-  AppStateStatus
+  AppStateStatus,
+  TextInput
 } from 'react-native';
 } from 'react-native';
 import {
 import {
   GiftedChat,
   GiftedChat,
@@ -125,6 +126,7 @@ const ChatScreen = ({ route }: { route: any }) => {
   const updateUnreadMessagesCount = useMessagesStore((state) => state.updateUnreadMessagesCount);
   const updateUnreadMessagesCount = useMessagesStore((state) => state.updateUnreadMessagesCount);
 
 
   const appState = useRef(AppState.currentState);
   const appState = useRef(AppState.currentState);
+  const textInputRef = useRef<TextInput>(null);
 
 
   const socket = useRef<WebSocket | null>(null);
   const socket = useRef<WebSocket | null>(null);
 
 
@@ -481,11 +483,25 @@ const ChatScreen = ({ route }: { route: any }) => {
           setHasMoreMessages(false);
           setHasMoreMessages(false);
         }
         }
 
 
+        if (mappedMessages.length === 0 && !modalInfo.visible) {
+          setTimeout(() => {
+            textInputRef.current?.focus();
+          }, 500);
+        }
+
         setIsLoadingEarlier(false);
         setIsLoadingEarlier(false);
       }
       }
     }, [chatData])
     }, [chatData])
   );
   );
 
 
+  useEffect(() => {
+    if (messages?.length === 0 && !modalInfo.visible) {
+      setTimeout(() => {
+        textInputRef.current?.focus();
+      }, 500);
+    }
+  }, [modalInfo]);
+
   const loadEarlierMessages = async () => {
   const loadEarlierMessages = async () => {
     if (!hasMoreMessages || isLoadingEarlier || !messages) return;
     if (!hasMoreMessages || isLoadingEarlier || !messages) return;
 
 
@@ -1203,6 +1219,7 @@ const ChatScreen = ({ route }: { route: any }) => {
             messageContainerRef={messageContainerRef}
             messageContainerRef={messageContainerRef}
             minComposerHeight={34}
             minComposerHeight={34}
             onInputTextChanged={(text) => handleTyping(text.length > 0)}
             onInputTextChanged={(text) => handleTyping(text.length > 0)}
+            textInputRef={textInputRef}
             isTyping={isTyping}
             isTyping={isTyping}
             renderSend={(props) => (
             renderSend={(props) => (
               <View style={styles.sendBtn}>
               <View style={styles.sendBtn}>

+ 1 - 1
src/screens/InAppScreens/MessagesScreen/ChatScreen/styles.tsx

@@ -95,7 +95,7 @@ export const styles = StyleSheet.create({
     borderColor: Colors.FILL_LIGHT
     borderColor: Colors.FILL_LIGHT
   },
   },
   emptyChat: {
   emptyChat: {
-    flex: 1,
+    height: '95%',
     alignItems: 'center',
     alignItems: 'center',
     justifyContent: 'center',
     justifyContent: 'center',
     transform: Platform.OS === 'ios' ? [{ scaleY: -1 }] : [{ scaleY: -1 }, { scaleX: -1 }]
     transform: Platform.OS === 'ios' ? [{ scaleY: -1 }] : [{ scaleY: -1 }, { scaleX: -1 }]

+ 12 - 11
src/screens/InAppScreens/MessagesScreen/Components/SearchUsersModal.tsx

@@ -37,17 +37,18 @@ const SearchModal = () => {
     <TouchableOpacity
     <TouchableOpacity
       style={styles.itemContainer}
       style={styles.itemContainer}
       onPress={() => {
       onPress={() => {
-        SheetManager.hide('search-modal');
-        navigation.navigate(
-          ...([
-            NAVIGATION_PAGES.CHAT,
-            {
-              id: item.user_id,
-              name: item.first_name + ' ' + item.last_name,
-              avatar: item.avatar
-            }
-          ] as never)
-        );
+        SheetManager.hide('search-modal').then(() => {
+          navigation.navigate(
+            ...([
+              NAVIGATION_PAGES.CHAT,
+              {
+                id: item.user_id,
+                name: item.first_name + ' ' + item.last_name,
+                avatar: item.avatar
+              }
+            ] as never)
+          );
+        });
       }}
       }}
     >
     >
       {item.avatar ? (
       {item.avatar ? (

+ 2 - 5
src/screens/InAppScreens/MessagesScreen/utils.ts

@@ -3,6 +3,7 @@ import * as Notifications from 'expo-notifications';
 import { Platform } from 'react-native';
 import { Platform } from 'react-native';
 import { NAVIGATION_PAGES } from 'src/types';
 import { NAVIGATION_PAGES } from 'src/types';
 import { usePushNotification } from 'src/contexts/PushNotificationContext';
 import { usePushNotification } from 'src/contexts/PushNotificationContext';
+import { CommonActions } from '@react-navigation/native';
 
 
 export const formatDate = (dateString: Date): string => {
 export const formatDate = (dateString: Date): string => {
   const inputDate = moment.utc(dateString).local();
   const inputDate = moment.utc(dateString).local();
@@ -35,11 +36,7 @@ export const dismissChatNotifications = async (
       type: 'success',
       type: 'success',
       message:
       message:
         'To use this feature we need your permission to access your notifications. You will be redirected to the notification settings screen where you need to enable them.',
         'To use this feature we need your permission to access your notifications. You will be redirected to the notification settings screen where you need to enable them.',
-      action: () =>
-        // @ts-ignore
-        navigation.navigate(NAVIGATION_PAGES.MENU_DRAWER, {
-          screen: NAVIGATION_PAGES.NOTIFICATIONS
-        })
+      action: () => navigation.navigate(NAVIGATION_PAGES.NOTIFICATIONS)
     });
     });
     return;
     return;
   }
   }