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 val observers = mutableMapOf<Long, ContentObserver>()
|
||||||
private var isPolling = false
|
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() {
|
public fun startPollersIfNeeded() {
|
||||||
refreshChatsAndPollers()
|
refreshChatsAndPollers()
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
|||||||
private val handler = Handler()
|
private val handler = Handler()
|
||||||
private var hasStarted = false
|
private var hasStarted = false
|
||||||
|
|
||||||
|
private var isCatchUp = false
|
||||||
|
|
||||||
// region Convenience
|
// region Convenience
|
||||||
private val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
private val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
private var displayNameUpdatees = setOf<String>()
|
private var displayNameUpdatees = setOf<String>()
|
||||||
@ -82,6 +84,14 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
|||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
fun isCatchUp(): Boolean {
|
||||||
|
return isCatchUp
|
||||||
|
}
|
||||||
|
|
||||||
|
fun shouldCatchUp() {
|
||||||
|
isCatchUp = false
|
||||||
|
}
|
||||||
|
|
||||||
// region Settings
|
// region Settings
|
||||||
companion object {
|
companion object {
|
||||||
private val pollForNewMessagesInterval: Long = 4 * 1000
|
private val pollForNewMessagesInterval: Long = 4 * 1000
|
||||||
@ -249,6 +259,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
|||||||
processIncomingMessage(message)
|
processIncomingMessage(message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
isCatchUp = true
|
||||||
}.fail {
|
}.fail {
|
||||||
Log.d("Loki", "Failed to get messages for group chat with ID: ${group.channel} on server: ${group.server}.")
|
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