Viktoriia 8 місяців тому
батько
коміт
1190336bc4

+ 4 - 0
Route.tsx

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

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

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

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

@@ -3,6 +3,7 @@ import * as Notifications from 'expo-notifications';
 import { Platform } from 'react-native';
 import { NAVIGATION_PAGES } from 'src/types';
 import { usePushNotification } from 'src/contexts/PushNotificationContext';
+import { CommonActions } from '@react-navigation/native';
 
 export const formatDate = (dateString: Date): string => {
   const inputDate = moment.utc(dateString).local();
@@ -35,11 +36,7 @@ export const dismissChatNotifications = async (
       type: 'success',
       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.',
-      action: () =>
-        // @ts-ignore
-        navigation.navigate(NAVIGATION_PAGES.MENU_DRAWER, {
-          screen: NAVIGATION_PAGES.NOTIFICATIONS
-        })
+      action: () => navigation.navigate(NAVIGATION_PAGES.NOTIFICATIONS)
     });
     return;
   }