forked from upstream-mirrors/quik
fix(compose): Prevent infinite loop on editing scheduled message
For some asinine reason, `state.scheduled` was observed than set with the same value, which was causing an infinite loop. `scheduled` is completely irrelevant to `canSend` anyway, as scheduled is essentially a boolean, and it is handled elsewhere.
This commit is contained in:
@@ -924,21 +924,18 @@ class ComposeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set canSend state depending on if there is text input, an attachment or a schedule set
|
// set canSend state depending on if there is text input or an attachment
|
||||||
Observables.combineLatest(
|
Observables.combineLatest(
|
||||||
view.textChangedIntent, // input message text changed
|
view.textChangedIntent,
|
||||||
state
|
state
|
||||||
.distinctUntilChanged { state -> state.attachments } // attachments changed
|
.distinctUntilChanged { state -> state.attachments }
|
||||||
.map { it.attachments.size }, // number of attachments
|
.map { it.attachments.size }
|
||||||
state.distinctUntilChanged { state -> state.scheduled } // schedule set or not
|
|
||||||
.map { it.scheduled }
|
|
||||||
)
|
)
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe {
|
.subscribe {
|
||||||
newState {
|
newState {
|
||||||
copy(
|
copy(
|
||||||
canSend = (it.first.isNotBlank() || (it.second > 0)),
|
canSend = (it.first.isNotBlank() || (it.second > 0))
|
||||||
scheduled = it.third
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user