Fixing too aggressive chat unhiding behavior

parent 1d99fb15
Pipeline #532 canceled with stages
in 4 seconds
......@@ -33,7 +33,6 @@ import de.kuschku.libquassel.connection.SocketAddress
import de.kuschku.libquassel.protocol.*
import de.kuschku.libquassel.quassel.BufferInfo
import de.kuschku.libquassel.quassel.QuasselFeatures
import de.kuschku.libquassel.quassel.syncables.BufferSyncer
import de.kuschku.libquassel.quassel.syncables.interfaces.IAliasManager
import de.kuschku.libquassel.session.ISession
import de.kuschku.libquassel.session.Session
......@@ -41,11 +40,7 @@ import de.kuschku.libquassel.session.SessionManager
import de.kuschku.libquassel.session.manager.ConnectionInfo
import de.kuschku.libquassel.util.compatibility.LoggingHandler.Companion.log
import de.kuschku.libquassel.util.compatibility.LoggingHandler.LogLevel.INFO
import de.kuschku.libquassel.util.flag.Flags
import de.kuschku.libquassel.util.flag.minus
import de.kuschku.libquassel.util.helper.clampOf
import de.kuschku.libquassel.util.helper.combineLatest
import de.kuschku.libquassel.util.helper.getOr
import de.kuschku.libquassel.util.helper.value
import de.kuschku.malheur.CrashHandler
import de.kuschku.quasseldroid.Backend
......@@ -420,38 +415,6 @@ class QuasselService : DaggerLifecycleService(),
}
})
var buffersWithNewActivity = emptySet<BufferId>()
combineLatest(
liveAccountId.switchMap { database.filtered().listenRx(it).toObservable() },
sessionManager.connectedSession
.map(ISession::bufferSyncer)
.switchMap(BufferSyncer::liveActivities)
).map { (filteredList, bufferActivities) ->
val filtered = filteredList.map {
Pair(it.bufferId, it.filtered)
}.toMap()
bufferActivities.mapValues { (bufferId, activities) ->
activities.minus(filtered.getOr(bufferId, 0).toUInt())
}.filterValues(Flags<Message_Type>::isNotEmpty).keys
}.map {
val newlyChangedBuffers = it - buffersWithNewActivity
buffersWithNewActivity = it
newlyChangedBuffers
}.map {
val bufferSyncer = sessionManager.connectedSession.value?.bufferSyncer
Pair(bufferSyncer, it.mapNotNull {
bufferSyncer?.bufferInfo(it)
})
}.toLiveData().observe(this, Observer { (bufferSyncer, bufferInfos) ->
val bufferViewManager = sessionManager.connectedSession.value?.bufferViewManager
if (bufferSyncer != null && bufferViewManager != null) {
for (bufferInfo in bufferInfos) {
bufferViewManager.handleBuffer(bufferInfo, bufferSyncer, unhide = true)
}
}
})
ReactiveNetwork
.observeNetworkConnectivity(applicationContext)
.toLiveData()
......
......@@ -26,6 +26,7 @@ import de.kuschku.libquassel.quassel.syncables.interfaces.IBufferSyncer
import de.kuschku.libquassel.session.ISession
import de.kuschku.libquassel.session.NotificationManager
import de.kuschku.libquassel.util.Optional
import de.kuschku.libquassel.util.flag.minus
import de.kuschku.libquassel.util.irc.IrcCaseMappers
import io.reactivex.Observable
import io.reactivex.subjects.BehaviorSubject
......@@ -150,7 +151,7 @@ class BufferSyncer constructor(
fun setActivities(data: List<Pair<BufferId, Message_Types>>) {
for ((buffer, activity) in data) {
setBufferActivity(buffer, activity)
setBufferActivityInternal(buffer, activity)
}
live_bufferActivities.onNext(Unit)
}
......@@ -275,12 +276,22 @@ class BufferSyncer constructor(
setBufferActivity(buffer, Message_Type.of(activity))
}
fun setBufferActivity(buffer: BufferId, activity: Message_Types) {
fun setBufferActivityInternal(buffer: BufferId, activity: Message_Types) {
super.setBufferActivity(buffer, activity.toInt())
_bufferActivities[buffer] = activity
live_bufferActivities.onNext(Unit)
}
fun setBufferActivity(buffer: BufferId, activity: Message_Types) {
val oldActivity = activity(buffer)
setBufferActivityInternal(buffer, activity)
if ((activity - oldActivity).isNotEmpty()) {
bufferInfo(buffer)?.let {
session.bufferViewManager.handleBuffer(it, this, true)
}
}
}
override fun setHighlightCount(buffer: BufferId, count: Int) {
super.setHighlightCount(buffer, count)
_highlightCounts[buffer] = count
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment