mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Remove some unnecessary call tab requeries.
This commit is contained in:
@@ -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!! }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user