-
Notifications
You must be signed in to change notification settings - Fork 1
[Feat] 온보딩 여부 저장 및 분기 처리 #38
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,5 +8,5 @@ | |
| enum UserDefaultsKey: String { | ||
| case nickname | ||
| case socialLoginType | ||
| case profileImageUrl | ||
| case onboarding | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
|
|
||
| import AuthenticationServices | ||
| import Combine | ||
| import Domain | ||
| import Shared | ||
| import SnapKit | ||
| import UIKit | ||
|
|
@@ -31,8 +32,10 @@ final class LoginView: BaseViewController<LoginViewModel> { | |
| private let kakaoLoginButton = SocialLoginButton(socialType: .kakao) | ||
| private let appleLoginButton = SocialLoginButton(socialType: .apple) | ||
| private var cancellables: Set<AnyCancellable> | ||
| private let onboardingRepository: OnboardingRepositoryProtocol | ||
|
|
||
| override init(viewModel: LoginViewModel) { | ||
| init(onboardingRepository: OnboardingRepositoryProtocol, viewModel: LoginViewModel) { | ||
| self.onboardingRepository = onboardingRepository | ||
| cancellables = [] | ||
| super.init(viewModel: viewModel) | ||
| } | ||
|
|
@@ -119,11 +122,18 @@ final class LoginView: BaseViewController<LoginViewModel> { | |
| let agreementView = TermsAgreementView(viewModel: self.viewModel) | ||
| self.navigationController?.pushViewController(agreementView, animated: true) | ||
| } else { | ||
| guard let onboardingViewModel = DIContainer.shared.resolve(type: OnboardingViewModel.self) else { | ||
| fatalError("onboardingViewModel 의존성이 등록되지 않았습니다.") | ||
| if onboardingRepository.isOnboardingDone() { | ||
| if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, | ||
| let window = windowScene.windows.first(where: { $0.isKeyWindow }) { | ||
| window.rootViewController = TabBarView() | ||
| } | ||
| } else { | ||
| guard let onboardingViewModel = DIContainer.shared.resolve(type: OnboardingViewModel.self) else { | ||
| fatalError("onboardingViewModel 의존성이 등록되지 않았습니다.") | ||
| } | ||
|
Comment on lines
+131
to
+133
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. 🛠️ Refactor suggestion OnboardingViewModel을 의존성으로 주입받도록 리팩토링 필요 현재 DIContainer에서 직접 resolve하는 방식은 의존성 주입 원칙에 위배됩니다. 다음과 같이 리팩토링하는 것을 제안합니다: private let onboardingRepository: OnboardingRepositoryProtocol
+private let onboardingViewModel: OnboardingViewModel
-init(onboardingRepository: OnboardingRepositoryProtocol, viewModel: LoginViewModel) {
+init(onboardingRepository: OnboardingRepositoryProtocol,
+ onboardingViewModel: OnboardingViewModel,
+ viewModel: LoginViewModel) {
self.onboardingRepository = onboardingRepository
+ self.onboardingViewModel = onboardingViewModel
cancellables = []
super.init(viewModel: viewModel)
}그리고 사용 부분을: -guard let onboardingViewModel = DIContainer.shared.resolve(type: OnboardingViewModel.self) else {
- fatalError("onboardingViewModel 의존성이 등록되지 않았습니다.")
-}
-let onboardingView = OnboardingView(viewModel: onboardingViewModel, onboarding: .time)
+let onboardingView = OnboardingView(viewModel: self.onboardingViewModel, onboarding: .time)🤖 Prompt for AI Agents |
||
| let onboardingView = OnboardingView(viewModel: onboardingViewModel, onboarding: .time) | ||
| self.navigationController?.pushViewController(onboardingView, animated: true) | ||
| } | ||
| let onboardingView = OnboardingView(viewModel: onboardingViewModel, onboarding: .time) | ||
| self.navigationController?.pushViewController(onboardingView, animated: true) | ||
| } | ||
| } | ||
| .store(in: &cancellables) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
💡 Verification agent
🧩 Analysis chain
온보딩 분기 처리 로직 검토
로그인 후 온보딩 완료 여부에 따른 분기 처리가 명확하게 구현되었습니다. 온보딩 미완료 시 OnboardingView로, 완료 시 TabBarView로 적절히 분기됩니다.
그런데 PR 목표에서 언급된 "여러 뷰에서 OnboardingRepository 인스턴스가 여러 개 생성되는 문제"를 고려해볼 필요가 있습니다. DI 컨테이너에서 싱글톤으로 관리하는지 확인해보시기 바랍니다.
다음 스크립트로 OnboardingRepository의 생성 패턴을 확인해보겠습니다:
🏁 Script executed:
Length of output: 11414
🏁 Script executed:
Length of output: 2879
OnboardingRepository 싱글톤 등록 필요성 검토
현재
DataSourceDependencyAssembler에서 아래와 같이 factory 방식으로OnboardingRepository를 등록하고 있어, DIContainer.resolve 호출 시마다 새로운 인스턴스가 생성됩니다.여러 뷰에서 resolve를 통해
OnboardingRepository가 반복 생성되는 현상을 방지하려면 싱글톤으로 공유되도록 등록 방식을 개선해야 합니다.수정 위치
Projects/DataSource/Sources/Common/DataSourceDependencyAssembler.swift
제안 변경 예시
또는 DIContainer 자체에 최초 생성된 인스턴스를 캐싱하는 로직을 추가하는 방법도 고려해 보세요.
🤖 Prompt for AI Agents
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.
이거슨 .. 9월에 DIContainer에 scope라는 개념을 도입할지 상의를 해볼게요 .. !!! ㅜㅜ
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.
@choijungp 네, 맞습니다! DIContainer에 scope 개념을 도입하는 것은 전체 아키텍처에 영향을 주는 큰 변경사항이니까 팀과 충분히 상의해서 결정하는 게 좋겠어요 👍
지금은 현재 방식대로 사용하시고, 9월에 scope 개념 도입을 검토해보시면 될 것 같습니다. 그때 singleton, transient 등의 lifecycle 관리를 체계적으로 정리하실 수 있을 거예요!
현재 구현으로도 기능상 문제는 없으니 우선 이대로 진행하시면 됩니다 😊
🧠 Learnings used