Skip to content
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

Merged
merged 4 commits into from
Sep 30, 2024

Conversation

Do-hyun-Kim
Copy link
Collaborator

@Do-hyun-Kim Do-hyun-Kim commented Sep 29, 2024

😽개요

  • AccountSignInViewReactor에 회원 정보 API 호출 코드 및 화면 전환 로직을 수정해요

🛠️작업 내용

AccountSignInViewReactor에 Member-info API 호출하여 해당 계정에 FamilyId를 조회하여 화면 전환 로직을 수정했습니다.

화면 전환 로직

AS-IS TO-BE

(소제목)

  • App.Repository.AccessToken을 구독하여Member-Info API를 호출하도록 하였습니다.
  • App.Repository를 구독한 이유는 초기 사용자 같은 경우 AccessToken 회원가입하지 않는 이상 AccessToken 값이 없기 때문에 구독 한 이후 Token 값을 여부를 판단하여 화면전환을 하기 위해서입니다.

🟡차후 계획

  • App.Repository같은 경우 BehaviorRelay로 정의되어 있기 때문에 해당 Repository에 accept가 될 경우 여러 번 이벤트가 방출됩니다. 예시) 회원 탈퇴 -> App.Repository.token.accessToken.accept(nil) -> 회원 가입 ->App.Repository.token.accessToken.accept(token) -> 총 2번 이벤트를 방출하게 됨
  • 추후 회원가입 플로우를 App.Repository.token.accessToken에서 구독하는 것이 아닌 UseCase를 활용해서 리팩토링 해야 할 것 같습니다.

✅테스트 케이스

  • 회원 탈퇴 시 온 보딩 화면을 보여주는 확인해요
  • 초기 회원가입 시 온 보딩 화면을 보여주는지 확인해요
  • 기존 사용자일 경우 홈 화면으로 넘어가는지 확인해요(Familyid 있을 경우)
  • FamilyId가 없는 사용자인 경우 가족방 생성 화면으로 넘어가는지 확인해요

issue: #662

- AccountSignInReactor meUseCase 및 SignInNavigator 추가
- OnboardingReactor updateIsFirstOnboardingUseCase 추가
…into fix/#662-login-logic-modify

* 'develop' of https://github.com/depromeet/14th-team5-iOS:
  알 수 없음 오류와 온보딩에서 화면이 넘어가지 않는 오류를 수정해요 (#663)

# Conflicts:
#	14th-team5-iOS/App/Sources/Presentation/OnBoarding/OnBoardingReactor.swift
- AccountResignViewReactor 회원 탈퇴시 isFirstOnboarding false 값으로 수정
- FetchIsFirstOnboardingUseCase 예외 처리 로직 추가
- AppUserDefaults 로직 수정
@rlarjsdn3
Copy link
Collaborator

App.Repository같은 경우 BehaviorRelay로 정의되어 있기 때문에 해당 Repository에 accept가 될 경우 여러 번 이벤트가 방출됩니다. 예시) 회원 탈퇴 -> App.Repository.token.accessToken.accept(nil) -> 회원 가입 ->App.Repository.token.accessToken.accept(token) -> 총 2번 이벤트를 방출하게 됨

이제 이해가 되네요.

@@ -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())
Copy link
Collaborator

Choose a reason for hiding this comment

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

요거는 @injected 사용해도 되는거 아닌가용??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

아 이부분 수정하겠습니다. :)

case .failed:
return .just(.kakaoLogin(false))
return .empty()
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기 failed일 때 toastMessage라도 띄워주는게 어떨까요?

Copy link
Collaborator

Choose a reason for hiding this comment

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

요 부분은 코드 싹다 리팩토링할 때 같이 하는게 좋아보여요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이것도 고민했는데 사실 저희가 저 코드는 수정할 코드이기도 하고

  • failed는 해당 소셜 계정 로그인 실패지만
  • 추후에 서버에서 주는 ResponseError를 보여주는 게 더 명확할 것 같다고 생각해서 Mutation에 추가 안 했어요

return .empty()
}
owner.signInNavigator.toOnboarding()
return .empty()
Copy link
Collaborator

Choose a reason for hiding this comment

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

결국 다 return .empty()하시는 것 같은데
마지막에 return .empty()하나 써주시고 중간에 if 분기처리만 진행해주시면 될 것 같아여!

@@ -145,6 +145,7 @@ final public class OnBoardingViewController: BaseViewController<OnBoardingReacto
@Navigator var onboardingNavigator: OnboardingNavigatorProtocol

if App.Repository.member.familyId.value == nil {
print("Onboarding ViewController to Join Family")
Copy link
Collaborator

Choose a reason for hiding this comment

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

요거는 지워주세용 ㅎ헤

akrudal
akrudal previously approved these changes Sep 30, 2024
@akrudal
Copy link
Collaborator

akrudal commented Sep 30, 2024

App.Repository같은 경우 BehaviorRelay로 정의되어 있기 때문에 해당 Repository에 accept가 될 경우 여러 번 이벤트가 방출됩니다. 예시) 회원 탈퇴 -> App.Repository.token.accessToken.accept(nil) -> 회원 가입 ->App.Repository.token.accessToken.accept(token) -> 총 2번 이벤트를 방출하게 됨

이제 이해가 되네요.

요래서 두 번 방출해서 어떤 문제가 있었나영?

@Do-hyun-Kim
Copy link
Collaborator Author

App.Repository같은 경우 BehaviorRelay로 정의되어 있기 때문에 해당 Repository에 accept가 될 경우 여러 번 이벤트가 방출됩니다. 예시) 회원 탈퇴 -> App.Repository.token.accessToken.accept(nil) -> 회원 가입 ->App.Repository.token.accessToken.accept(token) -> 총 2번 이벤트를 방출하게 됨

이제 이해가 되네요.

요래서 두 번 방출해서 어떤 문제가 있었나영?

대표적으로는 초기 사용자가 회원가입하고 온 보딩 화면까지 보면 isFirstOnboarding(true) 가 되는데

  • 회원 가입 이후에 AccountProfile 화면에서 App.Repository.token.accessToken.accept(token)을 호출하는데 이렇게 되면
  • isFirstOnboarding(false)인 경우로 한번 호출되고, isFirstOnboarding(true)로 한번 호출하게 되는 현상이 발생하게 돼요

@Do-hyun-Kim Do-hyun-Kim merged commit 29bdaa4 into develop Sep 30, 2024
0 of 2 checks passed
@Do-hyun-Kim Do-hyun-Kim deleted the fix/#662-login-logic-modify branch September 30, 2024 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants