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