Skip to content

Comments

Fix/#140 챌린지 탭 분기처리#145

Merged
y-eonee merged 2 commits intodevelopfrom
feat/#140-challengeviewprocessing
Jan 21, 2026
Merged

Fix/#140 챌린지 탭 분기처리#145
y-eonee merged 2 commits intodevelopfrom
feat/#140-challengeviewprocessing

Conversation

@y-eonee
Copy link
Contributor

@y-eonee y-eonee commented Jan 21, 2026

🔗 연결된 이슈

  • Closed: #140

📄 작업 내용

  • 어쩌구저쩌구
구현 내용 IPhone 16 pro IPhone 13 mini
GIF

@y-eonee y-eonee requested a review from a team January 21, 2026 14:13
@y-eonee y-eonee self-assigned this Jan 21, 2026
@y-eonee y-eonee requested review from soseoyo12, sum130 and wotjs020708 and removed request for a team January 21, 2026 14:13
@y-eonee y-eonee added 나연🐹 Fix 버그 수정 labels Jan 21, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

📝 Walkthrough

워크스루

사용자 진행 상태 플래그를 UserDefaults에 추가하여 영속성 지원을 확장하고, 저장소 계층에서 이 플래그를 관리하며, 코디네이터 뷰에서 조건부 초기 화면 표시 로직을 도입하고 라우팅 구조를 정리했습니다.

변경사항

코호트 / 파일 변경 요약
영속성 레이어
UserDefaultKey.swift
hasProgressChallenge 열거형 케이스 추가로 UserDefaults 키 확장
저장소 레이어
DemoRepository.swift, HomeRepository.swift
네트워크 응답 후 hasProgressChallenge 플래그를 동기화: fetchChallenges에서 true 저장, advance에서 충돌 오류 시 false 저장, HomeRepository에서 대시보드의 challengeName 여부에 따라 상태 결정
프레젠테이션 레이어 - 네비게이션
ChallengeCoordinator.swift, ChallengeCoordinatorView.swift
ChallengeRoute에서 root 케이스 제거, 초기 화면을 hasProgressChallenge 플래그 기반으로 선택 (true: ChallengeProgress, false: StartChallenge), 라우트별 onAppear 로직 추가 (탭바 표시/숨김)
프레젠테이션 레이어 - 뷰
ChallengeLoadingView.swift
강조 컴포넌트 텍스트 수정: "관리 방향을 바탕으로" → "방향을 바탕으로"

예상 코드 리뷰 노력

🎯 3 (보통) | ⏱️ ~25분

관련 가능성 있는 PR

제안 리뷰어

  • wotjs020708
  • sum130
  • soseoyo12
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive PR 설명에는 연결된 이슈(#140)와 '어쩌구저쩌구'라는 작업 내용이 있으나, 구체적인 구현 내용이 부족하고 이미지 자리표시자만 포함되어 있어 매우 불충분합니다. PR 설명에 변경사항의 구체적인 내용(hasProgressChallenge 플래그 추가, 조건부 뷰 전환 로직, UserDefaults 활용)을 명시하고 실제 스크린샷을 추가하여 보완해주세요.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 챌린지 탭의 분기 처리 기능을 구현하는 변경사항을 명확하게 설명하며, 실제 코드 변경(hasProgressChallenge 플래그 추가 및 조건부 뷰 전환)과 일치합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#140-challengeviewprocessing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@soseoyo12 soseoyo12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다

Copy link
Contributor

@wotjs020708 wotjs020708 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셧습니다.

Copy link
Contributor

@sum130 sum130 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어푸푸!

@y-eonee y-eonee merged commit 0ba533a into develop Jan 21, 2026
1 check was pending
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Cherrish-iOS/Cherrish-iOS/Data/Repository/DemoRepository.swift (1)

60-70: 미사용 변수 경고 가능성

response 변수가 선언되었지만 사용되지 않습니다. 의도적으로 응답을 무시하는 경우 _ = 패턴을 사용하거나, 향후 hasProgressChallenge를 true로 설정해야 한다면 해당 로직을 추가하는 것이 좋습니다.

♻️ 미사용 변수 처리
     func createChallenge(missionIds: Int, routineNames: [String]) async throws  {
         let userID: Int = userDefaultService.load(key: .userID) ?? 1
-        let response = try await networkService.request(
+        _ = try await networkService.request(
             DemoAPI.createChallenge(userID: userID, requestDTO:
                     .init(
                         homecareRoutineId: missionIds,
                         routineNames: routineNames
                     )
             )
         )
     }
🤖 Fix all issues with AI agents
In `@Cherrish-iOS/Cherrish-iOS/Data/Repository/DemoRepository.swift`:
- Around line 42-47: The catch block in DemoRepository.swift force-casts the
thrown error with `error as! CherrishError`, which can crash for
non-CherrishError errors; change this to a safe cast (e.g., `if let chErr =
error as? CherrishError` or `guard let chErr = error as? CherrishError else {
throw error }`) and only call `userDefaultService.save(false, key:
.hasProgressChallenge)` when `chErr == .conflict`, otherwise rethrow the
original error; update the catch in the function containing this logic to
perform the safe cast and conditional save before rethrowing.

In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/ChallengeView/Coordinator/ChallengeCoordinatorView.swift`:
- Line 13: Change ChallengeCoordinatorView to accept UserDefaultService via
constructor injection instead of instantiating DefaultUserDefaultService inline:
add an init(userDefaultService: UserDefaultService =
DefaultUserDefaultService()) that assigns to the existing userDefaultService
property, remove the direct DefaultUserDefaultService() initialization, and keep
the property typed as UserDefaultService so tests can inject a mock and callers
can rely on the default.

Comment on lines +42 to +47
} catch {
if error as! CherrishError == CherrishError.conflict {
let _ = userDefaultService.save(false, key: .hasProgressChallenge)
}
throw error
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Force cast 사용으로 인한 런타임 크래시 위험

error as! CherrishError는 error가 CherrishError 타입이 아닐 경우 앱이 크래시됩니다. 네트워크 에러, 디코딩 에러 등 다른 타입의 에러가 발생할 수 있으므로 안전한 캐스팅을 사용해야 합니다.

🐛 안전한 캐스팅으로 수정
         } catch {
-            if error as! CherrishError == CherrishError.conflict {
+            if let cherrishError = error as? CherrishError, cherrishError == .conflict {
                 let _ = userDefaultService.save(false, key: .hasProgressChallenge)
             }
             throw error
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch {
if error as! CherrishError == CherrishError.conflict {
let _ = userDefaultService.save(false, key: .hasProgressChallenge)
}
throw error
}
} catch {
if let cherrishError = error as? CherrishError, cherrishError == .conflict {
let _ = userDefaultService.save(false, key: .hasProgressChallenge)
}
throw error
}
🧰 Tools
🪛 SwiftLint (0.57.0)

[Error] 43-43: Force casts should be avoided

(force_cast)

🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Data/Repository/DemoRepository.swift` around lines
42 - 47, The catch block in DemoRepository.swift force-casts the thrown error
with `error as! CherrishError`, which can crash for non-CherrishError errors;
change this to a safe cast (e.g., `if let chErr = error as? CherrishError` or
`guard let chErr = error as? CherrishError else { throw error }`) and only call
`userDefaultService.save(false, key: .hasProgressChallenge)` when `chErr ==
.conflict`, otherwise rethrow the original error; update the catch in the
function containing this logic to perform the safe cast and conditional save
before rethrowing.

struct ChallengeCoordinatorView: View {
@EnvironmentObject private var challengeCoordinator: ChallengeCoordinator
@EnvironmentObject private var tabBarCoordinator: TabBarCoordinator
private let userDefaultService: UserDefaultService = DefaultUserDefaultService()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

🧩 Analysis chain

🏁 Script executed:

rg -n "UserDefaultService" --type swift -C2

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 10776


🏁 Script executed:

cat -n Cherrish-iOS/Cherrish-iOS/Presentation/Feature/ChallengeView/Coordinator/ChallengeCoordinatorView.swift

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 2055


🏁 Script executed:

cat -n Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Onboarding/SplashView.swift | head -20

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 669


의존성 주입 패턴 일관성 개선 필요

DefaultUserDefaultService()를 직접 인스턴스화하고 있습니다. 리포지토리들(HomeRepository, DemoRepository, ChallengeRepository 등)은 생성자 주입을 통해 UserDefaultService를 받고 있으며, SplashView처럼 같은 계층의 View 컴포넌트도 명시적 init() 메서드에서 기본 매개변수로 주입하는 패턴을 사용하고 있습니다.

다음과 같이 개선하면 테스트 시 mock 서비스 주입이 가능해지고 일관성이 향상됩니다:

init(userDefaultService: UserDefaultService = DefaultUserDefaultService()) {
    self.userDefaultService = userDefaultService
}
🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/ChallengeView/Coordinator/ChallengeCoordinatorView.swift`
at line 13, Change ChallengeCoordinatorView to accept UserDefaultService via
constructor injection instead of instantiating DefaultUserDefaultService inline:
add an init(userDefaultService: UserDefaultService =
DefaultUserDefaultService()) that assigns to the existing userDefaultService
property, remove the direct DefaultUserDefaultService() initialization, and keep
the property typed as UserDefaultService so tests can inject a mock and callers
can rely on the default.

@y-eonee y-eonee deleted the feat/#140-challengeviewprocessing branch January 21, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix 버그 수정 나연🐹

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants