mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
new approach for batch notification
This commit is contained in:
parent
b2827184a8
commit
6822bc461c
@ -207,7 +207,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
}
|
||||
startPollingIfNeeded();
|
||||
|
||||
OpenGroupManager.INSTANCE.markAllAsNotCaughtUp();
|
||||
OpenGroupManager.INSTANCE.setAllCaughtUp(false);
|
||||
OpenGroupManager.INSTANCE.startPolling();
|
||||
}
|
||||
|
||||
|
@ -19,21 +19,7 @@ object OpenGroupManager {
|
||||
private var pollers = mutableMapOf<String, OpenGroupPollerV2>() // One for each server
|
||||
private var isPolling = false
|
||||
|
||||
val isAllCaughtUp: Boolean
|
||||
get() {
|
||||
pollers.values.forEach { poller ->
|
||||
if (!poller.isCaughtUp) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun markAllAsNotCaughtUp() {
|
||||
pollers.values.forEach { poller ->
|
||||
poller.isCaughtUp = false
|
||||
}
|
||||
}
|
||||
var isAllCaughtUp = false
|
||||
|
||||
fun startPolling() {
|
||||
if (isPolling) { return }
|
||||
|
@ -56,6 +56,7 @@ import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.loki.api.OpenGroupManager;
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol;
|
||||
import org.thoughtcrime.securesms.loki.utilities.MentionUtilities;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
@ -286,6 +287,9 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
} finally {
|
||||
if (telcoCursor != null) telcoCursor.close();
|
||||
if (pushCursor != null) pushCursor.close();
|
||||
if (!OpenGroupManager.INSTANCE.isAllCaughtUp()) {
|
||||
OpenGroupManager.INSTANCE.setAllCaughtUp(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
@MainThread
|
||||
public OptimizedMessageNotifier(@NonNull MessageNotifier wrapped) {
|
||||
this.wrapped = wrapped;
|
||||
this.debouncer = new Debouncer(TimeUnit.SECONDS.toMillis(2));
|
||||
this.debouncer = new Debouncer(TimeUnit.SECONDS.toMillis(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,6 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
class OpenGroupPollerV2(private val server: String, private val executorService: ScheduledExecutorService?) {
|
||||
var hasStarted = false
|
||||
var isCaughtUp = false
|
||||
private var future: ScheduledFuture<*>? = null
|
||||
|
||||
companion object {
|
||||
@ -45,7 +44,6 @@ class OpenGroupPollerV2(private val server: String, private val executorService:
|
||||
handleNewMessages(openGroupID, response.messages, isBackgroundPoll)
|
||||
handleDeletedMessages(openGroupID, response.deletions)
|
||||
}
|
||||
isCaughtUp = true
|
||||
}.always {
|
||||
executorService?.schedule(this@OpenGroupPollerV2::poll, OpenGroupPollerV2.pollInterval, TimeUnit.MILLISECONDS)
|
||||
}.map { }
|
||||
|
Loading…
Reference in New Issue
Block a user