File tree Expand file tree Collapse file tree
viewModel/src/main/java/jp/dosukoi/ui/viewmodel/search
view/src/main/java/jp/dosukoi/ui/view/top Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,12 +28,8 @@ class MainActivity : AppCompatActivity() {
2828 private val myPageViewModel: MyPageViewModel by produceViewModels {
2929 myPageViewModelFactory.create(viewModel)
3030 }
31-
32- @Inject
33- lateinit var searchViewModelFactory: SearchViewModel .Factory
34- private val searchViewModel: SearchViewModel by produceViewModels {
35- searchViewModelFactory.create(viewModel)
36- }
31+
32+ private val searchViewModel: SearchViewModel by viewModels()
3733
3834 @Inject
3935 lateinit var compositionLocalProvider: CompositionLocalProvider
Original file line number Diff line number Diff line change @@ -81,7 +81,13 @@ class SearchViewModel @Inject constructor(
8181 }
8282 }
8383 _searchUiState .update {
84- it.copy(searchState = LoadState .Loading )
84+ when (val loadState = it.searchState) {
85+ is LoadState .Loaded -> when (loadState.data) {
86+ SearchState .Initialized , SearchState .Empty -> it.copy(searchState = LoadState .Loading )
87+ else -> it
88+ }
89+ else -> it.copy(searchState = LoadState .Loading )
90+ }
8591 }
8692 refresh(true )
8793 }
You can’t perform that action at this time.
0 commit comments