Skip to content

Conversation

@s9hn
Copy link
Member

@s9hn s9hn commented May 16, 2025

📌𝘐𝘴𝘴𝘶𝘦𝘴

📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯

  • 토큰 저장로직을 분리하고 모듈화했으므로, 기존 회원가입 로직 또한 옮겨주었습니다.
  • 네비게이터가 뷰 이동작업까지 applicationContext를 사용하고 있었습니다. 앱 컨텍스트를 사용하도록 수정했습니다.

💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴

Summary by CodeRabbit

  • Refactor

    • 로그인, 메인, 온보딩 화면 이동 시 내비게이터 메서드 호출 방식이 변경되어, 명시적으로 액티비티 실행 함수를 전달하도록 개선되었습니다.
    • 인증 관련 저장소에서 토큰 및 자동 로그인 상태 관리가 제거되어, 회원가입 및 닉네임 중복 확인 시 토큰 전달이 필요하지 않게 단순화되었습니다.
    • 일부 상수 및 불필요한 코드가 삭제되어 코드가 더 간결해졌습니다.
  • Bug Fixes

    • 인증 API 호출 시 Authorization 헤더가 더 이상 필요하지 않도록 수정되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented May 16, 2025

Walkthrough

이 변경사항은 네비게이터 관련 메서드의 시그니처를 (Intent) -> Unit 형태의 함수 참조를 받도록 일괄적으로 수정하고, SharedPreferences 기반의 토큰 및 자동 로그인 상태 관리를 제거하여 AuthRepository와 관련 ViewModel, Activity, Fragment, Module 등에서 인증 토큰 전달 및 저장 로직을 단순화합니다. AuthApi의 모든 인증 헤더 파라미터도 제거되었습니다.

Changes

파일/경로 그룹 변경 요약
.../WebsosoApp.kt
.../ui/accountInfo/LogoutDialogFragment.kt
.../ui/splash/SplashActivity.kt
.../ui/withdraw/second/WithdrawSecondActivity.kt
feature/signin/.../SignInScreen.kt
네비게이터의 navigateTo*Activity 호출 시 ::startActivity 또는 context::startActivity 함수 참조를 인자로 전달하도록 수정
.../core/common/util/navigator/WebsosoNavigator.kt
core/common/.../NavigatorProvider.kt
네비게이터 인터페이스 및 구현의 navigateTo*Activity 메서드가 (Intent) -> Unit 함수 파라미터를 받도록 시그니처 변경 및 내부 구현 수정
.../data/repository/AuthRepository.kt SharedPreferences 기반 토큰/자동 로그인 상태 관리 코드 및 관련 프로퍼티, 메서드 제거. API 호출 시 인증 토큰 파라미터 삭제 및 클래스에 @singleton 추가
.../data/di/RepositoryModule.kt AuthRepository 제공 함수 및 관련 import 제거
.../data/remote/api/AuthApi.kt 모든 API 메서드에서 @Header("Authorization") 파라미터 삭제 및 관련 import 제거
.../ui/onboarding/OnboardingViewModel.kt SavedStateHandle 및 토큰 관리 코드, 관련 파라미터와 프로퍼티 제거. AuthRepository 호출 시 토큰 전달 삭제
.../ui/onboarding/OnboardingActivity.kt ACCESS_TOKEN_KEY, REFRESH_TOKEN_KEY 상수 제거

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Activity/ViewModel/Composable
    participant Navigator as WebsosoNavigator
    participant System as Android System

    Caller->>Navigator: navigateToLoginActivity(::startActivity)
    Navigator->>Caller: (생성된 Intent 전달)
    Caller->>System: startActivity(Intent)
Loading

Assessment against linked issues

Objective Addressed Explanation
회원가입 로직에서 토큰 및 자동 로그인 상태 관리 리팩터링 (#690)
회원가입 및 닉네임 유효성 검사 시 인증 토큰 파라미터 제거 (#690)
네비게이터 메서드 시그니처 및 호출 방식 통일 (#690)

Possibly related PRs

Suggested reviewers

  • m6z1
  • yeonjeen
  • junseo511

Poem

🐰
토큰은 안녕, SharedPrefs도 굿바이
네비게이터는 함수로 손짓해
로그인, 온보딩, 메인으로
Intent만 들고 깡총깡총
한결 가벼워진 코드의 숲
오늘도 토끼는 리팩터링 춤!
🥕

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot requested review from junseo511, m6z1 and yeonjeen May 16, 2025 05:43
@s9hn s9hn added ♻️ [REFACTOR] 기존 코드를 리팩토링합니다. ⚖️ 재상 세훈 전지적 세훈 시점 labels May 16, 2025
@s9hn s9hn changed the title Feat/690 refactor: 회원가입 로직 수정 May 16, 2025
@s9hn
Copy link
Member Author

s9hn commented May 16, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented May 16, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented May 16, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

I'll help you review this pull request, @s9hn. Let me gather the necessary information about PR #691 first.


🏁 Script executed:

#!/bin/bash
# Get PR details
gh pr view 691 --json title,body,baseRefName,headRefName,state,additions,deletions,changedFiles

# List files changed in this PR
gh pr view 691 --json files --jq '.files[].path'

Length of output: 1393


Let me get the details of the changes in this PR to provide a thorough review.


🏁 Script executed:

#!/bin/bash
# Get PR diff to see the actual changes
gh pr diff 691

Length of output: 17643


@s9hn I've reviewed PR #691 which refactors the sign-up logic and navigation pattern. This is a very solid refactoring that improves the codebase in several important ways:

Navigation Pattern Improvements

  • The refactored NavigatorProvider interface now accepts a startActivity function parameter instead of directly calling context.startActivity()
  • This is a great improvement that follows dependency inversion principles and makes the code more testable
  • Using function references like ::startActivity or context::startActivity creates a cleaner separation between navigation logic and Android framework components

Authentication Logic Improvements

  • Token storage logic has been separated from AuthRepository
  • The repository now properly focuses on API communication only
  • Removed unnecessary token handling from OnboardingViewModel and OnboardingActivity
  • API endpoints no longer need to handle authorization headers directly

These changes make the codebase more maintainable and follow good software engineering practices by improving separation of concerns. The PR significantly reduces code (91 deletions vs 24 additions) while making it more modular.

Overall, this is a high-quality refactoring that improves the architecture. Approved! 👍

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: 1

🧹 Nitpick comments (2)
app/src/main/java/com/into/websoso/core/common/util/navigator/WebsosoNavigator.kt (1)

1-45: 함수형 인터페이스를 활용한 네비게이터 리팩토링에 대한 종합 의견

전체적인 네비게이터 구현이 함수형 프로그래밍 패러다임을 더 잘 활용하도록 개선되었습니다. 이러한 접근 방식은 다음과 같은 이점을 제공합니다:

  1. 의존성 주입 개선: 컨텍스트를 직접 사용하는 대신 함수 참조를 통해 액티비티 시작 로직을 주입
  2. 테스트 용이성: 실제 네비게이션 없이도 함수 호출 여부를 검증 가능
  3. 모듈 간 결합도 감소: 특정 컨텍스트나 라이프사이클에 덜 의존적
  4. 코드 재사용성 향상: 다양한 환경에서 동일한 네비게이션 로직 사용 가능

다만, 이 패턴을 적용하면서 모든 호출 지점이 올바르게 업데이트되었는지 확인하는 것이 중요합니다. PR 설명에 따르면 모든 관련 파일이 수정되었으므로 문제가 없을 것으로 보입니다.

app/src/main/java/com/into/websoso/data/repository/AuthRepository.kt (1)

15-15: 표준화된 Result 래퍼 반환 검토 권장
fetchNicknameValidityBoolean만 반환하면서 예외는 그대로 전파하도록 설계되었습니다. 호출부에서는 매번 runCatching { … } 또는 try‐catch로 감싸야 하므로 중복 코드가 늘어납니다.

Result<Boolean> 또는 자체 sealed class(예: Resource.Success, Resource.Error)를 반환하도록 리포지터리 레이어에서 통합 처리하면,

  • 호출부 간결화
  • 오류 유형 중앙 관리
  • 테스트 용이성
    을 기대할 수 있습니다.
    필요 시 도입을 검토해 주세요.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dd8942 and 3ffa1d8.

📒 Files selected for processing (12)
  • app/src/main/java/com/into/websoso/WebsosoApp.kt (1 hunks)
  • app/src/main/java/com/into/websoso/core/common/util/navigator/WebsosoNavigator.kt (2 hunks)
  • app/src/main/java/com/into/websoso/data/di/RepositoryModule.kt (0 hunks)
  • app/src/main/java/com/into/websoso/data/remote/api/AuthApi.kt (0 hunks)
  • app/src/main/java/com/into/websoso/data/repository/AuthRepository.kt (1 hunks)
  • app/src/main/java/com/into/websoso/ui/accountInfo/LogoutDialogFragment.kt (1 hunks)
  • app/src/main/java/com/into/websoso/ui/onboarding/OnboardingActivity.kt (0 hunks)
  • app/src/main/java/com/into/websoso/ui/onboarding/OnboardingViewModel.kt (1 hunks)
  • app/src/main/java/com/into/websoso/ui/splash/SplashActivity.kt (1 hunks)
  • app/src/main/java/com/into/websoso/ui/withdraw/second/WithdrawSecondActivity.kt (1 hunks)
  • core/common/src/main/java/com/into/websoso/core/common/navigator/NavigatorProvider.kt (1 hunks)
  • feature/signin/src/main/java/com/into/websoso/feature/signin/SignInScreen.kt (3 hunks)
💤 Files with no reviewable changes (3)
  • app/src/main/java/com/into/websoso/data/di/RepositoryModule.kt
  • app/src/main/java/com/into/websoso/ui/onboarding/OnboardingActivity.kt
  • app/src/main/java/com/into/websoso/data/remote/api/AuthApi.kt
🔇 Additional comments (13)
app/src/main/java/com/into/websoso/ui/splash/SplashActivity.kt (1)

42-43: 네비게이션 메서드 호출 방식의 일관성 있는 변경

이제 NavigatorProvider의 메서드들이 Activity 컨텍스트에서 startActivity 함수 참조를 받도록 변경되었습니다. 이 변경은 네비게이터 컴포넌트가 applicationContext 대신 앱 컨텍스트를 사용하도록 하는 PR 목표와 일치합니다.

app/src/main/java/com/into/websoso/ui/accountInfo/LogoutDialogFragment.kt (1)

36-36: 네비게이션 호출 패턴 통일

다른 Activity와 마찬가지로 navigateToLoginActivity 메서드에 ::startActivity 함수 참조를 전달하도록 수정되었습니다. 이 방식은 네비게이터가 Activity를 시작하는 방법에 대한 일관된 패턴을 제공합니다.

app/src/main/java/com/into/websoso/WebsosoApp.kt (1)

32-32: Application 컨텍스트에서 네비게이션 메서드 호출 방식 개선

Application 클래스에서도 네비게이션 메서드 호출 시 ::startActivity 함수 참조를 전달하도록 변경되었습니다. 이것은 PR에서 언급된 "네비게이터 컴포넌트가 applicationContext 대신 앱 컨텍스트를 사용하도록 수정" 목표와 일치합니다.

app/src/main/java/com/into/websoso/ui/withdraw/second/WithdrawSecondActivity.kt (1)

107-107: 토큰 저장 로직 분리에 따른 네비게이션 메서드 호출 수정

탈퇴 성공 후 로그인 화면으로 이동하는 코드가 새로운 패턴에 맞게 수정되었습니다. 이전에는 websosoNavigator.navigateToLoginActivity()를 호출했지만, 이제는 함수 참조 ::startActivity를 명시적으로 전달합니다. 이는 PR 목표인 "토큰 저장 로직을 모듈화하고 분리"하는 작업의 일환으로 보입니다.

feature/signin/src/main/java/com/into/websoso/feature/signin/SignInScreen.kt (2)

15-15: LocalContext 추가로 컨텍스트 관리 개선

LocalContext를 사용하여 현재 컴포즈 환경의 컨텍스트를 가져오는 방식은 적절합니다. 이렇게 하면 컴포저블 내에서 필요한 안드로이드 컨텍스트를 직접 접근할 수 있어 더 유연한 구현이 가능합니다.

Also applies to: 40-40


56-58: 네비게이터 호출 방식 개선

컨텍스트의 startActivity 메서드를 함수 참조로 전달하여 네비게이션 책임을 호출자에게 위임하는 방식으로 변경한 것은 좋은 리팩토링입니다. 이 패턴은 다음과 같은 이점이 있습니다:

  1. 관심사 분리: 네비게이터는 Intent 생성에만 집중하고, 실행은 호출자가 담당
  2. 테스트 용이성: 실제로 액티비티를 시작하지 않고도 네비게이션 로직을 검증 가능
  3. 유연성 향상: 호출자가 필요에 따라 Intent에 추가 정보를 더하거나 다양한 방식으로 처리 가능
core/common/src/main/java/com/into/websoso/core/common/navigator/NavigatorProvider.kt (2)

3-3: Intent 임포트 추가

Intent 클래스 임포트는 메서드 시그니처 변경에 따른 적절한 수정입니다.


9-13: 네비게이터 인터페이스 시그니처 개선

네비게이션 메서드의 시그니처를 (Intent) -> Unit 타입의 함수를 파라미터로 받도록 변경한 것은 좋은 설계 결정입니다. 이를 통해:

  1. 의존성 역전: 네비게이터가 액티비티 시작 책임을 직접 갖지 않고 호출자에게 위임
  2. 모듈 간 결합도 감소: 네비게이터 컴포넌트가 특정 컨텍스트에 덜 의존적
  3. 테스트 용이성: 함수형 인터페이스로 모킹이 더 쉬워짐

이러한 변경은 클린 아키텍처 원칙에 더 부합합니다.

app/src/main/java/com/into/websoso/core/common/util/navigator/WebsosoNavigator.kt (4)

4-4: Intent 임포트 추가

Intent 클래스 임포트는 메서드 파라미터 변경에 따른 적절한 수정입니다.


22-25: navigateToLoginActivity 메서드 개선

Intent 생성 후 호출자가 제공한 함수를 사용하여 액티비티를 시작하도록 변경한 것은 좋은 접근 방식입니다. 이를 통해 네비게이션 로직과 액티비티 시작 책임이 명확히 분리됩니다.


27-30: navigateToMainActivity 메서드 개선

MainActivity Intent 생성 후 호출자의 함수로 실행을 위임하는 방식으로 변경되었습니다. 이전 코드와 비교했을 때 더 유연하고 테스트하기 쉬운 구조로 개선되었습니다.


32-35: navigateToOnboardingActivity 메서드 개선

OnboardingActivity로의 네비게이션 역시 동일한 패턴으로 일관되게 개선되었습니다. 이제 모든 네비게이션 메서드가 동일한 패턴을 따르고 있어 코드의 일관성이 향상되었습니다.

app/src/main/java/com/into/websoso/data/repository/AuthRepository.kt (1)

9-10: @Singleton 추가 👍
리포지터리가 상태를 가지지 않는 구조로 변경되었으므로 싱글톤 스코프로 제공하는 것은 적절한 선택입니다. Hilt의 기본 컴포넌트 범위와도 잘 맞습니다.

Comment on lines 98 to 101
viewModelScope.launch {
runCatching {
authRepository.fetchNicknameValidity(accessToken, nickname)
authRepository.fetchNicknameValidity(nickname)
}.onSuccess { isNicknameValid ->
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

네트워크 호출은 IO 디스패처에서 수행하도록 분리하세요
viewModelScope.launch의 기본 디스패처는 Dispatchers.Main이기 때문에 현재 코드에서는 메인 스레드에서 API 호출이 실행될 수 있습니다. 레트로핏이 자체적으로 스레드 전환을 하도록 설정돼 있지 않다면 ANR 및 UI 지연이 발생할 여지가 있습니다.

아래와 같이 withContext(Dispatchers.IO)로 IO 스레드에서 실행되게 하시는 것을 권장드립니다.

             viewModelScope.launch {
-                runCatching {
-                    authRepository.fetchNicknameValidity(nickname)
-                }.onSuccess { isNicknameValid ->
+                runCatching {
+                    withContext(Dispatchers.IO) {
+                        authRepository.fetchNicknameValidity(nickname)
+                    }
+                }.onSuccess { isNicknameValid ->

추가로, withContext 사용 시 다음 import 가 필요합니다.

import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
🤖 Prompt for AI Agents
In app/src/main/java/com/into/websoso/ui/onboarding/OnboardingViewModel.kt
around lines 98 to 101, the network call inside viewModelScope.launch is running
on the main thread by default, which can cause UI delays or ANRs. To fix this,
wrap the network call authRepository.fetchNicknameValidity(nickname) inside
withContext(Dispatchers.IO) to ensure it runs on the IO dispatcher. Also, add
the necessary imports for Dispatchers and withContext.

@s9hn s9hn merged commit 5a161e4 into feat/657 May 16, 2025
2 checks passed
@m6z1 m6z1 deleted the feat/690 branch August 11, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♻️ [REFACTOR] 기존 코드를 리팩토링합니다. ⚖️ 재상 세훈 전지적 세훈 시점

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants