fix/ 补充打个招呼网络错误状态

This commit is contained in:
Kevin
2026-03-19 01:20:35 +08:00
parent 1d0f295169
commit faf7607bf9
3 changed files with 15 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
import { router } from 'expo-router';
import React from 'react';
import { Pressable, ScrollView, View } from 'react-native';
import { Alert, Pressable, ScrollView, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useTranslation } from 'react-i18next';
import { CheckCheck, MessageCirclePlus, User } from 'lucide-react-native';
@@ -8,6 +8,7 @@ import { CheckCheck, MessageCirclePlus, User } from 'lucide-react-native';
import { Icon } from '@/components/ui/icon';
import { Skeleton } from '@/components/ui/skeleton';
import { Text } from '@/components/ui/text';
import { NetworkError } from '@/core/api/types';
import {
useConversations,
useCreateConversation,
@@ -163,6 +164,15 @@ export default function ConversationsScreen() {
onSuccess: (result) => {
router.push(`/(main)/conversation/${result.id}`);
},
onError: (err) => {
const msg =
err instanceof NetworkError
? t('createError')
: err instanceof Error
? err.message
: t('createError');
Alert.alert(t('chatTitle'), msg, [{ text: t('confirm') }]);
},
});
};

View File

@@ -1,4 +1,6 @@
{
"createError": "Unable to create conversation. Please check your network and try again.",
"confirm": "OK",
"addMore": "More",
"agentName": "Life Echo",
"cancelRecording": "Cancel recording",

View File

@@ -1,4 +1,6 @@
{
"createError": "无法创建对话,请检查网络连接或稍后重试",
"confirm": "知道了",
"addMore": "更多功能",
"agentName": "岁月知己",
"cancelRecording": "取消录音发送",