-
Notifications
You must be signed in to change notification settings - Fork 0
운동 로직 수정 #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
운동 로직 수정 #126
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -605,12 +605,12 @@ const ExerciseScreen = ({ navigation }: any) => { | |
| typeof goalData.weeklyCalorieGoal === "number" && | ||
| goalData.weeklyCalorieGoal > 0 | ||
| ) { | ||
| parts.push(`${goalData.weeklyCalorieGoal}kcal`); | ||
| parts.push(`${goalData.weeklyCalorieGoal.toLocaleString()}kcal`); | ||
| } | ||
| if (parts.length === 0) { | ||
| return "목표치가 아직 설정되지 않았습니다"; | ||
| } | ||
| return `목표치 | ${parts.join(" · ")}`; | ||
| return `목표치 | ${parts.join(", ")}`; | ||
| }, [goalData]); | ||
|
|
||
| const trimmedCompletionTitle = completionSummaryTitle.trim(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 코드 패치는 몇 가지 문제점과 개선 사항이 있습니다.
따라서 이 코드를 머지하기 전에 자세한 테스트를 진행해보고, 의도한 형식과 구분자가 맞는지 확인하는 것이 좋습니다. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ import { | |
| } from "../../utils/inbodyApi"; | ||
| import AsyncStorage from "@react-native-async-storage/async-storage"; | ||
| import { eventBus } from "../../utils/eventBus"; | ||
| import InbodyDateNavigator from "../../components/common/InbodyDateNavigator"; | ||
| import InBodyCalendarModal from "../../components/common/InBodyCalendarModal"; | ||
| import { ROUTES } from "../../constants/routes"; | ||
| import { ACCESS_TOKEN_KEY } from "../../services/apiConfig"; | ||
|
|
@@ -1212,7 +1211,7 @@ const InBodyScreen = ({ navigation, route }: any) => { | |
| </View> | ||
| )} | ||
|
|
||
| {/* 날짜 네비게이터 */} | ||
| {/* 날짜 선택 바 (캘린더 버튼만) */} | ||
| {inBodyData && selectedDate && ( | ||
| <View style={styles.dateNavigatorContainer}> | ||
| <TouchableOpacity | ||
|
|
@@ -1227,15 +1226,6 @@ const InBodyScreen = ({ navigation, route }: any) => { | |
| </Text> | ||
| <Icon name="chevron-down" size={16} color="#E3FF7C" /> | ||
| </TouchableOpacity> | ||
| {availableDates.length > 0 && ( | ||
| <View style={styles.dateNavigatorWrapper}> | ||
| <InbodyDateNavigator | ||
| dates={availableDates} | ||
| onChange={handleDateNavigatorChange} | ||
| selectedDate={selectedDate} | ||
| /> | ||
| </View> | ||
| )} | ||
| </View> | ||
| )} | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 패치에 대한 몇 가지 우려 사항이 있습니다:
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -649,6 +649,18 @@ const HomeScreen = ({ navigation }: any) => { | |
| }; | ||
| }, []); | ||
|
|
||
| // 인바디 업데이트 이벤트 리스너 | ||
| useEffect(() => { | ||
| const unsubscribe = eventBus.on("inbodyUpdated", () => { | ||
| console.log("[HOME] 인바디 업데이트 이벤트 수신, 인바디 데이터 새로고침"); | ||
| loadInBodyData(); | ||
| }); | ||
|
|
||
| return () => { | ||
| unsubscribe?.(); | ||
| }; | ||
| }, []); | ||
|
|
||
| const handleCalendarClick = () => { | ||
| navigation.navigate("Calendar"); | ||
| }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코드 패치에 몇 가지 우려사항이 있습니다:
전반적으로 이 코드는 주의가 필요하며, 위의 사항들을 고려하여 개선할 필요가 있습니다. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드 리뷰
버그 및 위험 요소
sequenceIndex!사용:sequenceIndex!를 사용하고 있는데, 이는sequenceIndex가undefined일 수 있는 상황을 무시하는 것입니다. 이로 인해 런타임 에러가 발생할 가능성이 있습니다.!연산자는 타입스크립트에서 null 또는 undefined임을 명시적으로 방지하려 하지만, 실제 값이 존재하지 않을 경우 문제가 발생할 수 있습니다. 따라서, 이 부분에서 더 안전한 null 체크를 적용하는 것을 고려해야 합니다.의존성 경고:
canFinishWorkout의 값이allSetsCompleted와 같은 다른 상태들에 의존하고 있습니다. 만약 이러한 상태들이 변경될 경우,ExerciseModal가 올바르게 업데이트되지 않을 수 있습니다. 이 부분에 대한 의존성을 명확히 할 필요가 있습니다.성능 문제:
style배열에서canFinishWorkout값에 따라 동적으로 스타일을 변경하고 있습니다. 다수의 요소에서 동일한 방식으로 스타일을 설정할 경우 렌더링 성능에 영향을 줄 수 있습니다. 스타일을 미리 계산해두고 조건부로 적용하는 방법을 고려해볼 수 있습니다.개선 제안
sequenceIndex에 대한 보다 강력한 타입 검사를 추가하세요. 예를 들어, TypeScript로 검사할 때, 타입을 정의하여undefined인 경우에 대해 명확한 핸들링을 추가하는 것이 필요합니다.isLastSequence및canFinishWorkout연산 로직을 별도의 함수로 추출하여 가독성을 높이는 것도 좋습니다.