small change in signature

This commit is contained in:
Benoit Marty 2020-11-11 16:40:33 +01:00
parent d1e2d06538
commit 99bea8f7c3
1 changed files with 6 additions and 7 deletions

View File

@ -52,11 +52,10 @@ class ContactsBookController @Inject constructor(
override fun buildModels() {
val currentState = state ?: return
val hasSearch = currentState.searchTerm.isNotEmpty()
when (val asyncMappedContacts = currentState.mappedContacts) {
is Uninitialized -> renderEmptyState(false)
is Loading -> renderLoading()
is Success -> renderSuccess(currentState.filteredMappedContacts, hasSearch, currentState.onlyBoundContacts)
is Success -> renderSuccess(currentState)
is Fail -> renderFailure(asyncMappedContacts.error)
}
}
@ -75,13 +74,13 @@ class ContactsBookController @Inject constructor(
}
}
private fun renderSuccess(mappedContacts: List<MappedContact>,
hasSearch: Boolean,
onlyBoundContacts: Boolean) {
private fun renderSuccess(state: ContactsBookViewState) {
val mappedContacts = state.filteredMappedContacts
if (mappedContacts.isEmpty()) {
renderEmptyState(hasSearch)
renderEmptyState(state.searchTerm.isNotEmpty())
} else {
renderContacts(mappedContacts, onlyBoundContacts)
renderContacts(mappedContacts, state.onlyBoundContacts)
}
}