-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix: 로그인 시 메인화면 진입 못하는 이슈 수정해요 #665
Changes from all commits
b3ef425
8e86ec9
3fa3b34
c62a344
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 |
---|---|---|
|
@@ -17,7 +17,9 @@ public final class AccountSignInReactor: Reactor { | |
public var initialState: State | ||
@Injected var fetchIsFirstOnboardingUseCase: any FetchIsFirstOnboardingUseCaseProtocol | ||
private var accountRepository: AccountImpl = AccountRepository() | ||
private let meUseCase: MeUseCaseProtocol = MeUseCase(meRepository: MeAPIs.Worker()) | ||
private let fcmUseCase: FCMUseCaseProtocol = FCMUseCase(FCMRepository: MeAPIs.Worker()) | ||
@Navigator var signInNavigator: AccountSignInNavigatorProtocol | ||
private let disposeBag = DisposeBag() | ||
|
||
public enum Action { | ||
|
@@ -26,59 +28,49 @@ public final class AccountSignInReactor: Reactor { | |
} | ||
|
||
public enum Mutation { | ||
case kakaoLogin(Bool) | ||
case appleLogin(Bool) | ||
case setIsFirstOnboarding(Bool) | ||
|
||
} | ||
|
||
public struct State { | ||
var pushAccountSingUpVC: Bool | ||
@Pulse var isFirstOnboarding: Bool | ||
} | ||
|
||
init(/*accountRepository: AccountRepository, fcmUseCase: FCMUseCaseProtocol*/) { | ||
// self.accountRepository = accountRepository | ||
// self.fcmUseCase = fcmUseCase | ||
self.initialState = State( | ||
pushAccountSingUpVC: false, | ||
isFirstOnboarding: false | ||
) | ||
} | ||
} | ||
|
||
extension AccountSignInReactor { | ||
public func mutate(action: Action) -> Observable<Mutation> { | ||
let isFirstOnboarding = self.fetchIsFirstOnboardingUseCase.execute() == nil ? false : true | ||
switch action { | ||
case .kakaoLoginTapped(let sns, let vc): | ||
return accountRepository.kakaoLogin(with: sns, vc: vc) | ||
.flatMap { result -> Observable<Mutation> in | ||
.withUnretained(self) | ||
.flatMap { owner, result -> Observable<Mutation> in | ||
switch result { | ||
case .success: | ||
self.saveFCM() | ||
return .concat( | ||
.just(.kakaoLogin(true)), | ||
.just(.setIsFirstOnboarding(isFirstOnboarding)) | ||
) | ||
owner.saveFCM() | ||
return owner.transitionViewController() | ||
case .failed: | ||
return .just(.kakaoLogin(false)) | ||
return .empty() | ||
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. 여기 failed일 때 toastMessage라도 띄워주는게 어떨까요? 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 commentThe reason will be displayed to describe this comment to others. Learn more. 이것도 고민했는데 사실 저희가 저 코드는 수정할 코드이기도 하고
|
||
} | ||
} | ||
|
||
|
||
case .appleLoginTapped(let sns, let vc): | ||
return accountRepository.appleLogin(with: sns, vc: vc) | ||
.flatMap { result -> Observable<Mutation> in | ||
.withUnretained(self) | ||
.flatMap { owner, result -> Observable<Mutation> in | ||
switch result { | ||
case .success: | ||
self.saveFCM() | ||
return .concat( | ||
.just(.appleLogin(true)), | ||
.just(.setIsFirstOnboarding(isFirstOnboarding)) | ||
) | ||
return owner.transitionViewController() | ||
case .failed: | ||
return .just(.appleLogin(false)) | ||
return .empty() | ||
} | ||
} | ||
} | ||
|
@@ -87,10 +79,6 @@ extension AccountSignInReactor { | |
public func reduce(state: State, mutation: Mutation) -> State { | ||
var newState = state | ||
switch mutation { | ||
case .kakaoLogin(let result): | ||
newState.pushAccountSingUpVC = result | ||
case .appleLogin(let result): | ||
newState.pushAccountSingUpVC = result | ||
case let .setIsFirstOnboarding(isFirstOnboarding): | ||
newState.isFirstOnboarding = isFirstOnboarding | ||
} | ||
|
@@ -112,3 +100,40 @@ extension AccountSignInReactor { | |
} | ||
} | ||
} | ||
|
||
|
||
extension AccountSignInReactor { | ||
private func transitionViewController() -> Observable<Mutation> { | ||
let isFirstOnboarding = self.fetchIsFirstOnboardingUseCase.execute() | ||
return App.Repository.token.accessToken | ||
.skip(1) | ||
.withUnretained(self) | ||
.flatMapLatest { owner, token -> Observable<Mutation> in | ||
guard let token, | ||
let isTemporaryToken = token.isTemporaryToken else { | ||
return .empty() | ||
} | ||
|
||
if isTemporaryToken { | ||
owner.signInNavigator.toSignUp() | ||
return .empty() | ||
} | ||
|
||
return owner.meUseCase.getMemberInfo() | ||
.asObservable() | ||
.flatMap { memberInfo -> Observable<Mutation> in | ||
if isFirstOnboarding { | ||
if memberInfo?.familyId == nil { | ||
owner.signInNavigator.toJoinFamily() | ||
return .empty() | ||
} | ||
owner.signInNavigator.toMain() | ||
return .empty() | ||
} | ||
owner.signInNavigator.toOnboarding() | ||
return .empty() | ||
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. 결국 다 return .empty()하시는 것 같은데 |
||
} | ||
} | ||
} | ||
|
||
} |
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.
요거는 @injected 사용해도 되는거 아닌가용??
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.
아 이부분 수정하겠습니다. :)