Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/(help)/help.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ export default function HelpScreen() {
</MainLayout>
);
}

2 changes: 1 addition & 1 deletion app/(tabs-user)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function UserTabsLayout() {
<Tabs.Screen
name="diary"
options={{
title: "마음 일기",
title: "일기 작성",
tabBarIcon: ({ focused }) => (
<Icon
name={focused ? "NoteActive" : "NoteDisabled"}
Expand Down
10 changes: 5 additions & 5 deletions app/(tabs-user)/chat-list/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import {

import { queries } from "@/entities";
import {
getChatHistory,
type ChatHistoryResponse,
type ChatMessage,
cleanupExpiredPendingChatMessages,
getChatHistory,
getPendingChatMessages,
removePendingChatMessage,
type ChatHistoryResponse,
type ChatMessage,
} from "@/entities/chatbot";
import { normalizeEmotion } from "@/shared/lib/emotions";
import { BackHeader, MainLayout } from "@/shared/ui";
import { BackHeader, HelpButton, MainLayout } from "@/shared/ui";
import { ChatBubble, ChatInput, DiaryBottomSheet, VoiceMessageModal, VoicePlaybackModal } from "@/widgets/chat";
import { useSendMessage } from "@/widgets/chat/model/useSendMessage";

Expand Down Expand Up @@ -356,7 +356,7 @@ export default function ChatDetailScreen() {
return (
<MainLayout className="items-stretch">
<MainLayout.Header>
<BackHeader title={title} />
<BackHeader title={title} rightComponent={<HelpButton />} />
</MainLayout.Header>

<KeyboardAvoidingView
Expand Down
3 changes: 1 addition & 2 deletions app/(tabs-user)/diary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ export default function DiaryScreen() {
Alert.alert("오류", "서버 업로드 중 문제가 발생했습니다.");
},
onSettled: () => {

queryClient.invalidateQueries({ queryKey: queries.voices._def });
queryClient.invalidateQueries({ queryKey: queries.questions._def });
queryClient.invalidateQueries({ queryKey: queries.chatbot._def });
Expand All @@ -279,7 +278,7 @@ export default function DiaryScreen() {
return (
<MainLayout className="bg-gray-50">
<MainLayout.Header>
<MainHeader title="마음 일기" rightComponent={<HelpButton />} />
<MainHeader title="일기 작성" rightComponent={<HelpButton />} />
</MainLayout.Header>
<ScrollView
className="flex-1 w-full"
Expand Down
4 changes: 2 additions & 2 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isAxiosError } from "axios";
import { useFonts } from "expo-font";
import {
Redirect,
Slot,
Stack,
useRootNavigationState,
useSegments,
} from "expo-router";
Expand Down Expand Up @@ -146,7 +146,7 @@ export default function RootLayout() {
<SafeAreaProvider>
<QueryClientProvider client={queryClient}>
<FcmProvider>
<Slot />
<Stack screenOptions={{ headerShown: false }} />
</FcmProvider>
</QueryClientProvider>
</SafeAreaProvider>
Expand Down
4 changes: 2 additions & 2 deletions shared/ui/buttons/help-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export const HelpButton = () => {
const router = useRouter();

const handlePress = () => {
router.push('/(help)/help');
router.push("/(help)/help");
};
return (
<TouchableOpacity className="flex-row items-center justify-center gap-x-1" onPress={handlePress}>
<Icon name="HeaderQuestionIcon" />
</TouchableOpacity>
);
};
};
4 changes: 2 additions & 2 deletions shared/ui/header/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type HeaderProps = {
title: string;
navigateTo?: Href<any>;
rightComponent?: React.ReactNode;
}
};

export const BackHeader = ({ title, navigateTo, rightComponent }: HeaderProps) => {
const router = useRouter();
Expand Down Expand Up @@ -34,4 +34,4 @@ export const BackHeader = ({ title, navigateTo, rightComponent }: HeaderProps) =
)}
</View>
);
};
};
34 changes: 24 additions & 10 deletions widgets/chat/report/ui/weekly-story.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useIsMutating, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useEffect, useMemo } from "react";
import { noop, useIsMutating, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useEffect, useMemo, useRef } from "react";
import { ActivityIndicator, Text, View } from "react-native";

import { FluentSparkleIcon } from "@/assets/icons";
import { queries } from "@/entities";
import { createWeeklyReport, type WeeklyReportItem } from "@/entities/chatbot";
import { normalizeEmotion } from "@/shared/lib/emotions";
import { Icon } from "@/shared/ui";

export const WeeklyStory = ({ username }: { username: string }) => {
const queryClient = useQueryClient();
Expand Down Expand Up @@ -46,6 +47,12 @@ export const WeeklyStory = ({ username }: { username: string }) => {
// mutation key 생성
const createWeeklyReportMutationKey = ["createWeeklyReport", username, currentWeekStart];

// 같은 주에 대해 생성 요청을 한 번만 시도하기 위한 ref (404/무데이터 시 무한 재시도 방지)
const triedCreateForWeekRef = useRef<string | null>(null);
if (triedCreateForWeekRef.current !== null && triedCreateForWeekRef.current !== currentWeekStart) {
triedCreateForWeekRef.current = null;
}

// mutation이 진행 중인지 확인
const isMutating = useIsMutating({
mutationKey: createWeeklyReportMutationKey,
Expand Down Expand Up @@ -96,6 +103,7 @@ export const WeeklyStory = ({ username }: { username: string }) => {
target_date: currentWeekStart,
});
},
onError: noop,
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: queries.chatbot.monthlyReports(username, year, month).queryKey,
Expand All @@ -120,19 +128,19 @@ export const WeeklyStory = ({ username }: { username: string }) => {

const is404Error = isError && (error as any)?.response?.status === 404;

// 같은 주에 대해 이미 생성 시도를 했으면 다시 호출하지 않음 (404/무데이터 시 무한 재시도 방지)
if (triedCreateForWeekRef.current === currentWeekStart) {
return;
}

if (is404Error) {
console.log("[WeeklyStory] 주간 리포트 생성 이유: monthlyReports API에서 404 에러 발생", {
username,
year,
month,
currentWeekStart,
currentWeekEnd,
});
triedCreateForWeekRef.current = currentWeekStart;
createWeeklyStory();
return;
}

if (!isError && !currentWeekReport) {
triedCreateForWeekRef.current = currentWeekStart;
const hasReports = monthlyReports?.reports && monthlyReports.reports.length > 0;
const reason = !monthlyReports?.reports
? "monthlyReports 데이터가 없음"
Expand Down Expand Up @@ -209,7 +217,13 @@ export const WeeklyStory = ({ username }: { username: string }) => {
</View>
</View>
</View>
) : null}
) : (
<View className="h-[80px] bg-gray10 rounded-[16px] justify-center items-center">
<Icon name="AlertCircle" size={24} />
<Text className="text-gray70 text-[13px] mt-1">{
error?.response?.data?.message ?? "금주 대화가 없어 생성할 수 없습니다."}</Text>
</View>
)}
</View>
);
};