-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: 즐겨찾기 화면 기능 분리 #13
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
base: hoya
Are you sure you want to change the base?
Conversation
| storeAdapter = StoreAdapter( | ||
| storeItems = storeViewModel.storeItems.value ?: mutableListOf(), | ||
| favoriteItems = favoriteViewModel.favoriteState.value ?: emptyList(), | ||
| onFavoriteClicked = { storeId -> |
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.
맨 처음에는 로딩이 다 되지 않았으니까 아이템들이 항상 빈 리스트로 들어가게 되지 않을까요?
| degreeViewModel = ViewModelProvider(this)[DegreeViewModel::class.java] | ||
| storeViewModel = ViewModelProvider(this)[StoreViewModel::class.java] | ||
| favoriteViewModel = ViewModelProvider(this)[FavoriteViewModel::class.java] | ||
| filterViewModel = ViewModelProvider(this)[FilterViewModel::class.java] |
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.
FilterViewModel의 역할이 무엇인가요?
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.
4가지 필터(단체, 데이트, 가성비, 제휴)의 체크 상태를(true, false) 관리하는 뷰모델입니다
| import com.example.ssul.model.StoreModel | ||
|
|
||
| class StoreAdapter( | ||
| private var storeItems: MutableList<StoreModel>, |
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.
storeItems를 MutableList로 하신 이유가 있을까요?
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.
처음 개발할 때 즐겨찾기 화면에서 즐겨찾기 제거 시 해당 아이템을 직접 제거 하려고 MutableList로 했던 것 같은데, 지금 다시 보니 새로운 가게 리스트를 넘겨 받아 대체하는 식으로 되어있어서 크게 의미가 없네요!
| storeItems = if (isFavoriteMode) { // FavoriteFragment | ||
| newItems.filter { store -> | ||
| favoriteItems.any { favorite -> favorite.storeId == store.id && favorite.isFavorite } | ||
| }.toMutableList() | ||
| } else { // HomeFragment | ||
| newItems.toMutableList() | ||
| } |
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.
이렇게 매번 연산하지 말고 그냥 StoreModel 내에 isFavorite 같은 플래그를 두는 건 어떨까요?
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.
좋은 것 같아요!
Summary
Describe your changes
To reviewers