|
@@ -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}>
|