forked from upstream-mirrors/quik
Improve readability for recipient changing observable
This commit is contained in:
@@ -99,11 +99,14 @@ class ComposeViewModel(threadId: Long) : QkViewModel<ComposeView, ComposeState>(
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe { contacts -> newState { it.copy(contacts = contacts) } }
|
.subscribe { contacts -> newState { it.copy(contacts = contacts) } }
|
||||||
|
|
||||||
|
|
||||||
intents += Observable.merge(
|
intents += Observable.merge(
|
||||||
view.chipDeletedIntent.map { contact -> { contacts: List<Contact> -> contacts.filterNot { it == contact } } },
|
view.chipDeletedIntent.doOnNext { contact ->
|
||||||
view.chipSelectedIntent.map { contact -> { contacts: List<Contact> -> contacts.toMutableList().apply { add(contact) } } })
|
contactsReducer.onNext { contacts -> contacts.filterNot { it == contact } }
|
||||||
.subscribe { reducer -> contactsReducer.onNext { reducer(it) } }
|
},
|
||||||
|
view.chipSelectedIntent.doOnNext { contact ->
|
||||||
|
contactsReducer.onNext { contacts -> contacts.toMutableList().apply { add(contact) } }
|
||||||
|
})
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
intents += view.textChangedIntent.subscribe { text ->
|
intents += view.textChangedIntent.subscribe { text ->
|
||||||
newState { it.copy(draft = text.toString(), canSend = text.isNotEmpty()) }
|
newState { it.copy(draft = text.toString(), canSend = text.isNotEmpty()) }
|
||||||
|
|||||||
Reference in New Issue
Block a user