mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-23 06:08:52 +01:00
Simplify ComposeState editingMode checks
This commit is contained in:
@@ -178,8 +178,8 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
|
|||||||
.combineLatest(view.queryChangedIntent, selectedContacts, { query, selectedContacts ->
|
.combineLatest(view.queryChangedIntent, selectedContacts, { query, selectedContacts ->
|
||||||
selectedContacts.isEmpty() || query.isNotEmpty()
|
selectedContacts.isEmpty() || query.isNotEmpty()
|
||||||
})
|
})
|
||||||
.skipUntil(state.filter { state -> state.editingMode == true })
|
.skipUntil(state.filter { state -> state.editingMode })
|
||||||
.takeUntil(state.filter { state -> state.editingMode == false })
|
.takeUntil(state.filter { state -> !state.editingMode })
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { contactsVisible -> newState { it.copy(contactsVisible = contactsVisible && it.editingMode) } }
|
.subscribe { contactsVisible -> newState { it.copy(contactsVisible = contactsVisible && it.editingMode) } }
|
||||||
@@ -192,8 +192,8 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
|
|||||||
.filterNot { contact -> selectedContacts.contains(contact) }
|
.filterNot { contact -> selectedContacts.contains(contact) }
|
||||||
.filter { contact -> contactFilter.filter(contact, query) }
|
.filter { contact -> contactFilter.filter(contact, query) }
|
||||||
})
|
})
|
||||||
.skipUntil(state.filter { state -> state.editingMode == true })
|
.skipUntil(state.filter { state -> state.editingMode })
|
||||||
.takeUntil(state.filter { state -> state.editingMode == false })
|
.takeUntil(state.filter { state -> !state.editingMode })
|
||||||
.subscribeOn(Schedulers.computation())
|
.subscribeOn(Schedulers.computation())
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { contacts -> newState { it.copy(contacts = contacts) } }
|
.subscribe { contacts -> newState { it.copy(contacts = contacts) } }
|
||||||
@@ -206,8 +206,8 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
|
|||||||
view.chipSelectedIntent.doOnNext { contact ->
|
view.chipSelectedIntent.doOnNext { contact ->
|
||||||
contactsReducer.onNext { contacts -> contacts.toMutableList().apply { add(contact) } }
|
contactsReducer.onNext { contacts -> contacts.toMutableList().apply { add(contact) } }
|
||||||
})
|
})
|
||||||
.skipUntil(state.filter { state -> state.editingMode == true })
|
.skipUntil(state.filter { state -> state.editingMode })
|
||||||
.takeUntil(state.filter { state -> state.editingMode == false })
|
.takeUntil(state.filter { state -> !state.editingMode })
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe()
|
.subscribe()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user