From 62fc01924c3311128d5c0b02fc3e508dbf8b817a Mon Sep 17 00:00:00 2001 From: taerim Date: Fri, 22 Aug 2025 14:29:43 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=83=88=EB=A1=9C=EA=B3=A0=EC=B9=A8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Time-Up/App.tsx | 14 ++++---- .../pages/Alarm/WakeUp/WakeUpAlarmPage.tsx | 36 ++++++++----------- Time-Up/src/pages/Diary/DiaryPage.tsx | 18 +++++++++- .../src/pages/Onboarding/OnboardingPage.tsx | 21 +++++------ 4 files changed, 49 insertions(+), 40 deletions(-) diff --git a/Time-Up/App.tsx b/Time-Up/App.tsx index 8fdab4f..8d0cbaa 100644 --- a/Time-Up/App.tsx +++ b/Time-Up/App.tsx @@ -43,7 +43,6 @@ import SetRemindAlarmPage from './src/pages/SetPage/SetRemindAlarmPage'; import SetScheduleRepeatPage from './src/pages/SetScheduleRepeatPage'; import ViewScheduleDetailPage from './src/pages/ViewScheduleDetailPage'; -import { saveFCMPushToken } from './src/apis/pushToken'; import { getAccessToken } from './src/utils/storage'; import { requestWebPushToken } from './src/utils/webPush'; @@ -114,6 +113,7 @@ export default function App() { // }, []); useEffect(() => { + //debugger; if (Platform.OS !== 'web') return; if (webPushInitRef.current) return; webPushInitRef.current = true; @@ -128,12 +128,12 @@ export default function App() { } console.log('Web FCM Token:', token); - const res = await saveFCMPushToken(token); - if ((res as any)?.result === 'Error') { - console.warn('웹 push-token 저장 실패:', (res as any)?.error); - } else { - console.log('웹 push-token 저장 성공'); - } + // const res = await saveFCMPushToken(token); + // if ((res as any)?.result === 'Error') { + // console.warn('웹 push-token 저장 실패:', (res as any)?.error); + // } else { + // console.log('웹 push-token 저장 성공'); + // } } catch (e) { console.warn('웹 푸시 토큰 발급/저장 실패:', e); } diff --git a/Time-Up/src/pages/Alarm/WakeUp/WakeUpAlarmPage.tsx b/Time-Up/src/pages/Alarm/WakeUp/WakeUpAlarmPage.tsx index 34e51e8..2472018 100644 --- a/Time-Up/src/pages/Alarm/WakeUp/WakeUpAlarmPage.tsx +++ b/Time-Up/src/pages/Alarm/WakeUp/WakeUpAlarmPage.tsx @@ -102,14 +102,6 @@ export default function WakeUpAlarmPage() { } }; - // const handleToggleSwitchForDay = (day: Day) => { - // setWeekdaySwitchStates(prev => { - // const next = { ...prev, [day]: !prev[day] }; - // console.log(`${day} 기상알람이 ${next[day] ? '켜졌습니다' : '꺼졌습니다'}.`); - // return next; - // }); - // }; - const handleMyPage = () => { console.log('내 알람 페이지로 이동합니다.'); navigation.navigate('MyAlarmPage'); @@ -140,20 +132,20 @@ export default function WakeUpAlarmPage() { const { refreshAlarms } = useAlarmContext(); const syncedOnceRef = useRef(false); - // useEffect(() => { - // // 알람 동기화 - // if (!syncedOnceRef.current) { - // syncedOnceRef.current = true; - // (async () => { - // try { - // await refreshAlarms(); - // console.log('알람 동기화 성공'); - // } catch (e) { - // console.warn('초기 알람 동기화 실패(무시 가능):', e); - // } - // })(); - // } - // }, [navigation, refreshAlarms]); + useEffect(() => { + // 알람 동기화 + if (!syncedOnceRef.current) { + syncedOnceRef.current = true; + (async () => { + try { + await refreshAlarms(); + console.log('알람 동기화 성공'); + } catch (e) { + console.warn('초기 알람 동기화 실패(무시 가능):', e); + } + })(); + } + }, [navigation, refreshAlarms]); return ( diff --git a/Time-Up/src/pages/Diary/DiaryPage.tsx b/Time-Up/src/pages/Diary/DiaryPage.tsx index 40d445d..24d7c07 100644 --- a/Time-Up/src/pages/Diary/DiaryPage.tsx +++ b/Time-Up/src/pages/Diary/DiaryPage.tsx @@ -1,10 +1,11 @@ import Modal from '@/src/components/common/Modal'; import DateModal from '@/src/components/diary/DateModal'; +import { useAlarmContext } from '@/src/contexts/AlarmContext'; import useAppNavigation from '@/src/hooks/useAppNavigation'; import { useGetDiaryList } from '@/src/hooks/useDiaries'; import moment from 'moment'; import React, { useRef, useState } from 'react'; -import { ActivityIndicator, Animated, Dimensions, FlatList, SafeAreaView, Text, TextInput, TouchableOpacity, View} from 'react-native'; +import { ActivityIndicator, Animated, Dimensions, FlatList, SafeAreaView, Text, TextInput, TouchableOpacity, View } from 'react-native'; import { DateData } from 'react-native-calendars'; import PlusIcon from '../../../assets/images/PlusIcon.svg'; import SearchIcon from '../../../assets/images/SearchIcon.svg'; @@ -23,9 +24,24 @@ export default function DiaryPage() { const [isSearchModalVisible, setSearchModalVisible] = useState(false); const [isAlertModalVisible, setAlertModalVisible] = useState(false); const [alertMessage, setAlertMessage] = useState(''); + const syncedOnceRef = useRef(false); + const { refreshAlarms } = useAlarmContext(); const { data: diaries = [], isLoading } = useGetDiaryList(); + // useEffect(() => { + + // if (!syncedOnceRef.current) { + // syncedOnceRef.current = true; + // try { + // await refreshAlarms(); + // } catch (e) { + // console.warn('초기 알람 동기화 실패(무시 가능):', e); + // } + // } + // }) + + const handlePressAdd = () => { navigation.navigate('DiaryWritePage'); }; diff --git a/Time-Up/src/pages/Onboarding/OnboardingPage.tsx b/Time-Up/src/pages/Onboarding/OnboardingPage.tsx index 93f5e3a..5733029 100644 --- a/Time-Up/src/pages/Onboarding/OnboardingPage.tsx +++ b/Time-Up/src/pages/Onboarding/OnboardingPage.tsx @@ -67,18 +67,19 @@ export default function OnboardingPage() { } if (data.success?.isNew) { - // try { - // await refreshAlarms(); - // } catch (e) { - // console.warn('초기 알람 동기화 실패(무시 가능):', e); - // } + debugger; + try { + await refreshAlarms(); + } catch (e) { + console.warn('초기 알람 동기화 실패(무시 가능):', e); + } navigation.navigate('ProfileSettingPage', {}); } else { - // try { - // await refreshAlarms(); - // } catch (e) { - // console.warn('초기 알람 동기화 실패(무시 가능):', e); - // } + try { + await refreshAlarms(); + } catch (e) { + console.warn('초기 알람 동기화 실패(무시 가능):', e); + } navigation.navigate('CalendarPage'); } } catch (error: any) {