mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
add flag in public chat poller for catching up
This commit is contained in:
parent
106c22d9d2
commit
7cc60e6173
@ -20,6 +20,24 @@ class LokiPublicChatManager(private val context: Context) {
|
||||
private val observers = mutableMapOf<Long, ContentObserver>()
|
||||
private var isPolling = false
|
||||
|
||||
public fun isAllCatchUp():Boolean {
|
||||
var isAllCatchUp = true
|
||||
refreshChatsAndPollers()
|
||||
for ((threadId, chat) in chats) {
|
||||
val poller = pollers[threadId] ?: LokiPublicChatPoller(context, chat)
|
||||
isAllCatchUp = isAllCatchUp() && poller.isCatchUp()
|
||||
}
|
||||
return isAllCatchUp
|
||||
}
|
||||
|
||||
public fun shouldAllCatchUp() {
|
||||
refreshChatsAndPollers()
|
||||
for ((threadId, chat) in chats) {
|
||||
val poller = pollers[threadId] ?: LokiPublicChatPoller(context, chat)
|
||||
poller.shouldCatchUp()
|
||||
}
|
||||
}
|
||||
|
||||
public fun startPollersIfNeeded() {
|
||||
refreshChatsAndPollers()
|
||||
|
||||
|
@ -35,6 +35,8 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
||||
private val handler = Handler()
|
||||
private var hasStarted = false
|
||||
|
||||
private var isCatchUp = false
|
||||
|
||||
// region Convenience
|
||||
private val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||
private var displayNameUpdatees = setOf<String>()
|
||||
@ -82,6 +84,14 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
||||
}
|
||||
// endregion
|
||||
|
||||
fun isCatchUp(): Boolean {
|
||||
return isCatchUp
|
||||
}
|
||||
|
||||
fun shouldCatchUp() {
|
||||
isCatchUp = false
|
||||
}
|
||||
|
||||
// region Settings
|
||||
companion object {
|
||||
private val pollForNewMessagesInterval: Long = 4 * 1000
|
||||
@ -249,6 +259,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
||||
processIncomingMessage(message)
|
||||
}
|
||||
}
|
||||
isCatchUp = true
|
||||
}.fail {
|
||||
Log.d("Loki", "Failed to get messages for group chat with ID: ${group.channel} on server: ${group.server}.")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user