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

refactor: 즐겨찾기 화면 기능 분리 #13

Open
wants to merge 3 commits into
base: hoya
Choose a base branch
from

Conversation

hoyaboi
Copy link
Collaborator

@hoyaboi hoyaboi commented Feb 16, 2025

Summary

  • 즐겨찾기 화면(FavoritesFragment)의기능 분리, MVVM 적용

Describe your changes

  • DegreeViewModel : FavoritesFragment에서 학과 정보를 옵저빙하기 위해, 해당 뷰모델에서 학교 정보와 학과 정보 관리
  • FavoritesFragment : 학과 정보 수정 기능, 즐겨찾기 추가된 가게 표시 기능, 필터 기능 분리

To reviewers

  • 발생한 문제 : 다른 프래그먼트 혹은 액티비티에서 즐겨찾기 상태 수정 후, 현재 프래그먼트의 즐겨찾기 ui가 바로 반영되지 않는 문제 발생(HomeFragment와 FavoritesFragment 해결 필요)

@hoyaboi hoyaboi changed the title Refactor/hoya/favorites refactor: 즐겨찾기 가게 표시 화면 기능 분리 Feb 16, 2025
@hoyaboi hoyaboi changed the title refactor: 즐겨찾기 가게 표시 화면 기능 분리 refactor: 즐겨찾기 화면 기능 분리 Feb 16, 2025
Comment on lines +327 to +330
storeAdapter = StoreAdapter(
storeItems = storeViewModel.storeItems.value ?: mutableListOf(),
favoriteItems = favoriteViewModel.favoriteState.value ?: emptyList(),
onFavoriteClicked = { storeId ->

Choose a reason for hiding this comment

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

맨 처음에는 로딩이 다 되지 않았으니까 아이템들이 항상 빈 리스트로 들어가게 되지 않을까요?

degreeViewModel = ViewModelProvider(this)[DegreeViewModel::class.java]
storeViewModel = ViewModelProvider(this)[StoreViewModel::class.java]
favoriteViewModel = ViewModelProvider(this)[FavoriteViewModel::class.java]
filterViewModel = ViewModelProvider(this)[FilterViewModel::class.java]

Choose a reason for hiding this comment

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

FilterViewModel의 역할이 무엇인가요?

@@ -17,7 +17,8 @@ class StoreAdapter(
private var storeItems: MutableList<StoreModel>,

Choose a reason for hiding this comment

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

storeItems를 MutableList로 하신 이유가 있을까요?

Comment on lines +104 to +110
storeItems = if (isFavoriteMode) { // FavoriteFragment
newItems.filter { store ->
favoriteItems.any { favorite -> favorite.storeId == store.id && favorite.isFavorite }
}.toMutableList()
} else { // HomeFragment
newItems.toMutableList()
}

Choose a reason for hiding this comment

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

이렇게 매번 연산하지 말고 그냥 StoreModel 내에 isFavorite 같은 플래그를 두는 건 어떨까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants