mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Clean
This commit is contained in:
parent
2a88de3f61
commit
d09171213d
@ -226,9 +226,9 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
executePendingContactSync();
|
||||
KeyCachingService.onAppForegrounded(this);
|
||||
// Loki
|
||||
if (lokiPoller != null) { lokiPoller.shouldCatchUp(); }
|
||||
if (lokiPoller != null) { lokiPoller.setCaughtUp(false); }
|
||||
startPollingIfNeeded();
|
||||
lokiPublicChatManager.shouldAllCatchUp();
|
||||
lokiPublicChatManager.markAllAsNotCaughtUp();
|
||||
lokiPublicChatManager.startPollersIfNeeded();
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,6 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
private long messageId;
|
||||
private long smsMessageId;
|
||||
|
||||
//Loki
|
||||
private MessageNotifier messageNotifier;
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
@ -20,21 +20,21 @@ class LokiPublicChatManager(private val context: Context) {
|
||||
private val observers = mutableMapOf<Long, ContentObserver>()
|
||||
private var isPolling = false
|
||||
|
||||
public fun isAllCatchUp():Boolean {
|
||||
var isAllCatchUp = true
|
||||
public fun areAllCaughtUp():Boolean {
|
||||
var areAllCaughtUp = true
|
||||
refreshChatsAndPollers()
|
||||
for ((threadId, chat) in chats) {
|
||||
val poller = pollers[threadId] ?: LokiPublicChatPoller(context, chat)
|
||||
isAllCatchUp = isAllCatchUp() && poller.isCatchUp()
|
||||
for ((threadID, chat) in chats) {
|
||||
val poller = pollers[threadID] ?: LokiPublicChatPoller(context, chat)
|
||||
areAllCaughtUp = areAllCaughtUp && poller.isCaughtUp
|
||||
}
|
||||
return isAllCatchUp
|
||||
return areAllCaughtUp
|
||||
}
|
||||
|
||||
public fun shouldAllCatchUp() {
|
||||
public fun markAllAsNotCaughtUp() {
|
||||
refreshChatsAndPollers()
|
||||
for ((threadId, chat) in chats) {
|
||||
val poller = pollers[threadId] ?: LokiPublicChatPoller(context, chat)
|
||||
poller.shouldCatchUp()
|
||||
for ((threadID, chat) in chats) {
|
||||
val poller = pollers[threadID] ?: LokiPublicChatPoller(context, chat)
|
||||
poller.isCaughtUp = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,7 @@ import java.util.*
|
||||
class LokiPublicChatPoller(private val context: Context, private val group: LokiPublicChat) {
|
||||
private val handler = Handler()
|
||||
private var hasStarted = false
|
||||
|
||||
private var isCatchUp = false
|
||||
public var isCaughtUp = false
|
||||
|
||||
// region Convenience
|
||||
private val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||
@ -84,14 +83,6 @@ 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
|
||||
@ -259,7 +250,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
||||
processIncomingMessage(message)
|
||||
}
|
||||
}
|
||||
isCatchUp = true
|
||||
isCaughtUp = true
|
||||
}.fail {
|
||||
Log.d("Loki", "Failed to get messages for group chat with ID: ${group.channel} on server: ${group.server}.")
|
||||
}
|
||||
|
@ -2,18 +2,17 @@ package org.thoughtcrime.securesms.notifications;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.loki.api.LokiPublicChatManager;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Debouncer;
|
||||
import org.thoughtcrime.securesms.util.Throttler;
|
||||
import org.whispersystems.signalservice.loki.api.LokiPoller;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
private final MessageNotifier wrapped;
|
||||
private final Debouncer debouncer;
|
||||
@ -42,12 +41,12 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
public void updateNotification(@NonNull Context context) {
|
||||
LokiPoller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
||||
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
||||
Boolean isCatchUp = false;
|
||||
Boolean isCaughtUp = false;
|
||||
if (lokiPoller != null && lokiPublicChatManager != null) {
|
||||
isCatchUp = lokiPoller.isCatchUp() && lokiPublicChatManager.isAllCatchUp();
|
||||
isCaughtUp = lokiPoller.isCaughtUp() && lokiPublicChatManager.areAllCaughtUp();
|
||||
}
|
||||
|
||||
if (isCatchUp) {
|
||||
if (isCaughtUp) {
|
||||
wrapped.updateNotification(context);
|
||||
} else {
|
||||
debouncer.publish(() -> wrapped.updateNotification(context));
|
||||
@ -58,12 +57,12 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
public void updateNotification(@NonNull Context context, long threadId) {
|
||||
LokiPoller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
||||
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
||||
Boolean isCatchUp = false;
|
||||
Boolean isCaughtUp = false;
|
||||
if (lokiPoller != null && lokiPublicChatManager != null) {
|
||||
isCatchUp = lokiPoller.isCatchUp() && lokiPublicChatManager.isAllCatchUp();
|
||||
isCaughtUp = lokiPoller.isCaughtUp() && lokiPublicChatManager.areAllCaughtUp();
|
||||
}
|
||||
|
||||
if (isCatchUp) {
|
||||
if (isCaughtUp) {
|
||||
wrapped.updateNotification(context, threadId);
|
||||
} else {
|
||||
debouncer.publish(() -> wrapped.updateNotification(context, threadId));
|
||||
@ -74,12 +73,12 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
public void updateNotification(@NonNull Context context, long threadId, boolean signal) {
|
||||
LokiPoller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
||||
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
||||
Boolean isCatchUp = false;
|
||||
Boolean isCaughtUp = false;
|
||||
if (lokiPoller != null && lokiPublicChatManager != null) {
|
||||
isCatchUp = lokiPoller.isCatchUp() && lokiPublicChatManager.isAllCatchUp();
|
||||
isCaughtUp = lokiPoller.isCaughtUp() && lokiPublicChatManager.areAllCaughtUp();
|
||||
}
|
||||
|
||||
if (isCatchUp) {
|
||||
if (isCaughtUp) {
|
||||
wrapped.updateNotification(context, threadId, signal);
|
||||
} else {
|
||||
debouncer.publish(() -> wrapped.updateNotification(context, threadId, signal));
|
||||
@ -90,19 +89,18 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
public void updateNotification(@android.support.annotation.NonNull Context context, boolean signal, int reminderCount) {
|
||||
LokiPoller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
||||
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
||||
Boolean isCatchUp = false;
|
||||
Boolean isCaughtUp = false;
|
||||
if (lokiPoller != null && lokiPublicChatManager != null) {
|
||||
isCatchUp = lokiPoller.isCatchUp() && lokiPublicChatManager.isAllCatchUp();
|
||||
isCaughtUp = lokiPoller.isCaughtUp() && lokiPublicChatManager.areAllCaughtUp();
|
||||
}
|
||||
|
||||
if (isCatchUp) {
|
||||
if (isCaughtUp) {
|
||||
wrapped.updateNotification(context, signal, reminderCount);
|
||||
} else {
|
||||
debouncer.publish(() -> wrapped.updateNotification(context, signal, reminderCount));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clearReminder(@NonNull Context context) { wrapped.clearReminder(context); }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user