f
This commit is contained in:
parent
062f8f0b3a
commit
432e9b9dfb
@ -1,18 +1,16 @@
|
||||
import ReturnArrow from "@/assets/icons/svg/returnArrow.svg";
|
||||
import Chat from "@/components/ask/chat";
|
||||
import SendMessage from "@/components/ask/send";
|
||||
import { ThemedText } from "@/components/ThemedText";
|
||||
import { useWebSocketStreamHandler } from "@/hooks/useWebSocketStreamHandler";
|
||||
import { fetchApi } from "@/lib/server-api-util";
|
||||
import { Message } from "@/types/ask";
|
||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||
import React, { useRef, useState } from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
Animated,
|
||||
FlatList,
|
||||
Keyboard,
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
StyleSheet,
|
||||
TextInput,
|
||||
TouchableOpacity,
|
||||
@ -174,32 +172,32 @@ export default function AskScreen() {
|
||||
// fadeAnimChat.value = withTiming(isHello ? 0 : 1, { duration: 300 });
|
||||
// }, [isHello]);
|
||||
|
||||
// useEffect(() => {
|
||||
// if (sessionId && isMountedRef.current) {
|
||||
// setConversationId(sessionId);
|
||||
// setIsHello(false);
|
||||
useEffect(() => {
|
||||
if (sessionId && isMountedRef.current) {
|
||||
setConversationId(sessionId);
|
||||
setIsHello(false);
|
||||
|
||||
// // 创建新的AbortController
|
||||
// abortControllerRef.current = new AbortController();
|
||||
// 创建新的AbortController
|
||||
abortControllerRef.current = new AbortController();
|
||||
|
||||
// fetchApi<Message[]>(`/chats/${sessionId}/message-history`, {
|
||||
// signal: abortControllerRef.current.signal
|
||||
// }).then((res) => {
|
||||
// if (isMountedRef.current) {
|
||||
// console.log("isMountedRef.current", isMountedRef.current)
|
||||
// setUserMessages(res);
|
||||
// }
|
||||
// }).catch((error) => {
|
||||
// if (error.name !== 'AbortError') {
|
||||
// console.error('获取消息历史失败:', error);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// if (newSession && isMountedRef.current) {
|
||||
// setIsHello(true);
|
||||
// setConversationId(null);
|
||||
// }
|
||||
// }, [sessionId, newSession]);
|
||||
fetchApi<Message[]>(`/chats/${sessionId}/message-history`, {
|
||||
signal: abortControllerRef.current.signal
|
||||
}).then((res) => {
|
||||
if (isMountedRef.current) {
|
||||
console.log("isMountedRef.current", isMountedRef.current)
|
||||
setUserMessages(res);
|
||||
}
|
||||
}).catch((error) => {
|
||||
if (error.name !== 'AbortError') {
|
||||
console.error('获取消息历史失败:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (newSession && isMountedRef.current) {
|
||||
setIsHello(true);
|
||||
setConversationId(null);
|
||||
}
|
||||
}, [sessionId, newSession]);
|
||||
|
||||
// useEffect(() => {
|
||||
// if (!isHello && isMountedRef.current) {
|
||||
@ -281,7 +279,7 @@ export default function AskScreen() {
|
||||
</View>
|
||||
|
||||
{/* 输入框区域 */}
|
||||
<KeyboardAvoidingView
|
||||
{/* <KeyboardAvoidingView
|
||||
behavior={Platform.OS === "ios" ? "padding" : "height"}
|
||||
keyboardVerticalOffset={0} >
|
||||
<View style={styles.inputContainer} key={conversationId}>
|
||||
@ -294,7 +292,7 @@ export default function AskScreen() {
|
||||
setSelectedImages={setSelectedImages}
|
||||
/>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</KeyboardAvoidingView> */}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user