Remove some unnecessary call tab requeries.
This commit is contained in:
parent
4b21e6a39f
commit
878900c09c
3 changed files with 22 additions and 0 deletions
|
@ -82,6 +82,7 @@ class CallLogViewModel(
|
|||
disposables += AppDependencies
|
||||
.signalCallManager
|
||||
.peekInfoCache
|
||||
.skipWhile { cache -> cache.isEmpty() || cache.values.all { it.isCompletelyInactive } }
|
||||
.observeOn(Schedulers.computation())
|
||||
.distinctUntilChanged()
|
||||
.subscribe {
|
||||
|
|
|
@ -17,6 +17,10 @@ data class CallLinkPeekInfo(
|
|||
val isActive: Boolean,
|
||||
val isJoined: Boolean
|
||||
) {
|
||||
|
||||
val isCompletelyInactive
|
||||
get() = callId == null && !isActive && !isJoined
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromPeekInfo(peekInfo: PeekInfo): CallLinkPeekInfo {
|
||||
|
|
|
@ -73,3 +73,20 @@ fun <S : Subject<T>, T : Any> Single<T>.subscribeWithSubject(
|
|||
|
||||
return subject
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the first item emitted from the flowable, but only if it matches the provided [predicate].
|
||||
*/
|
||||
fun <T : Any> Flowable<T>.skipFirstIf(predicate: (T) -> Boolean): Flowable<T> {
|
||||
return this
|
||||
.scan(Pair<Boolean, T?>(false, null)) { acc, item ->
|
||||
val firstItemInList = !acc.first
|
||||
if (firstItemInList && predicate(item)) {
|
||||
true to null
|
||||
} else {
|
||||
true to item
|
||||
}
|
||||
}
|
||||
.filter { it.second != null }
|
||||
.map { it.second!! }
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue