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

[BUG] #117 : 탐색 화면의 검색 조건이 초기화되는 이슈 수정 #118

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

aurora32s
Copy link
Contributor

📌 내용

기존에는 메인 탭에서 탐색 화면으로 검색 조건을 emit하는 flow가 있어,
앱이 background로 갔다가 다시 돌아왔을 때 기존 검색 조건을 유지하지 못하는 이슈가 있었습니다.

🛠 해결 방법

[기존]

  • 검색 조건을 ProductFragment에서 생성한 ProductViewModel에서 관리

[수정]

  • ProductViewModel을 ProductFragment가 속한 Activity(MainActivity, ExploreActivity)에서 주입받고 ProductFragment에서는 이러한 ViewModel을 가져다 사용하도록 수정
  • 검색 조건을 한 곳에서 관리하기 때문에 중복 문제 및 Background에서 돌아왔을 때 초기화 문제 해결

@aurora32s aurora32s added bug Something isn't working 🌹진연주(AOS) 담당 개발자 - 진연주(안드로이드) labels Oct 8, 2023
@aurora32s aurora32s added this to the FIX milestone Oct 8, 2023
@aurora32s aurora32s self-assigned this Oct 8, 2023
@aurora32s aurora32s changed the title [BUG]: 탐색 화면의 검색 조건이 초기화되는 이슈 수정 #117 [BUG] #117 : 탐색 화면의 검색 조건이 초기화되는 이슈 수정 Oct 8, 2023
Copy link
Member

@jiwon2724 jiwon2724 left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다~~!:sunglasses::sunglasses: 이제 편의점에서 수월하게 사용 가능하겠군요!

궁금한 부분 코멘트 남겼습니당 혹시 주석 처리하신 부분은 사용 안 되는 부분이 맞을까요~?

override fun bindingFactory(): ActivityExploreActivityBinding = ActivityExploreActivityBinding.inflate(layoutInflater)

override fun initViews() {
println(exploreViewModel)
productViewModel
Copy link
Member

Choose a reason for hiding this comment

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

이렇게 ViewModel 하나만 있어도 괜찮나요~?.?

Comment on lines +22 to +23
private val productViewModel: ProductViewModel by viewModels { ProductViewModel.ProductViewModelFactory(productRepository) }
private val mainViewModel: MainViewModel by viewModels { MainViewModel.MainViewModelFactory() }
Copy link
Member

Choose a reason for hiding this comment

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

궁금한게 있읍니다 ㅎㅎ by viewModels()로 하면 해당부분 ViewModelFactory 필요한 부분 일까요?.?

Comment on lines +6 to +8
interface PageActivity {
fun moveToEvaluatePage()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

요거 navigator 이용하면 되지 않나욤?

Comment on lines +175 to +183
// private fun observeKeyword() {
// viewLifecycleOwner.lifecycleScope.launch {
// viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
// exploreViewModel.productSearchCondition.collect {
// productViewModel.setProductSearchCondition(it)
// }
// }
// }
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

주석은 지워도 될 듯!

moveToConditionExplore = productSearchableViewModel::changeSortType,
moveToStoreExplore = productSearchableViewModel::changeStoreType
moveToConditionExplore = {
(requireActivity() as? PageActivity)?.moveToEvaluatePage()
Copy link
Contributor

Choose a reason for hiding this comment

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

as?로 체크할거면 activity 쓰는게 안전할 것 같아요~

@@ -38,6 +44,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {

override fun initViews() {
binding.rvHome.adapter = homeAdapter
// productSearchableViewModel
Copy link
Contributor

Choose a reason for hiding this comment

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

요기도 주석 지워주세요~


override fun initViews() {
productViewModel
Copy link
Contributor

Choose a reason for hiding this comment

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

요거는 어떤 코드일까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌹진연주(AOS) 담당 개발자 - 진연주(안드로이드) bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants