Go back to search mode if all contacts are removed

This commit is contained in:
moezbhatti
2019-10-30 21:26:43 -04:00
committed by Moez Bhatti
parent cd368dddfc
commit 132a6543b7
2 changed files with 10 additions and 2 deletions
@@ -27,7 +27,9 @@ import com.moez.QKSMS.R
import com.moez.QKSMS.model.Recipient
import kotlinx.android.synthetic.main.group_avatar_view.view.*
class GroupAvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(context, attrs) {
class GroupAvatarView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null
) : ConstraintLayout(context, attrs) {
var contacts: List<Recipient> = ArrayList()
set(value) {
@@ -324,7 +324,13 @@ class ComposeViewModel @Inject constructor(
// Update the list of selected contacts when a new contact is selected or an existing one is deselected
Observable.merge(
view.chipDeletedIntent.doOnNext { contact ->
contactsReducer.onNext { contacts -> contacts.filterNot { it == contact } }
contactsReducer.onNext { contacts ->
val result = contacts.filterNot { it == contact }
if (result.isEmpty()) {
newState { copy(searching = true) }
}
result
}
},
view.chipSelectedIntent.doOnNext { composeItem ->
newState { copy(searching = false) }