diff --git a/src/org/thoughtcrime/securesms/notifications/OptimizedMessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/OptimizedMessageNotifier.java index 3b335f9909..12ae011499 100644 --- a/src/org/thoughtcrime/securesms/notifications/OptimizedMessageNotifier.java +++ b/src/org/thoughtcrime/securesms/notifications/OptimizedMessageNotifier.java @@ -42,9 +42,13 @@ public class OptimizedMessageNotifier implements MessageNotifier { public void updateNotification(@NonNull Context context) { Poller lokiPoller = ApplicationContext.getInstance(context).lokiPoller; LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager; - boolean isCaughtUp = false; - if (lokiPoller != null && lokiPublicChatManager != null) { - isCaughtUp = lokiPoller.isCaughtUp() && lokiPublicChatManager.areAllCaughtUp(); + boolean isCaughtUp = true; + if (lokiPoller != null) { + isCaughtUp = isCaughtUp && lokiPoller.isCaughtUp(); + } + + if (lokiPublicChatManager != null) { + isCaughtUp = isCaughtUp && lokiPublicChatManager.areAllCaughtUp(); } if (isCaughtUp) { @@ -58,11 +62,15 @@ public class OptimizedMessageNotifier implements MessageNotifier { public void updateNotification(@NonNull Context context, long threadId) { Poller lokiPoller = ApplicationContext.getInstance(context).lokiPoller; LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager; - boolean isCaughtUp = false; - if (lokiPoller != null && lokiPublicChatManager != null) { - isCaughtUp = lokiPoller.isCaughtUp() && lokiPublicChatManager.areAllCaughtUp(); + boolean isCaughtUp = true; + if (lokiPoller != null) { + isCaughtUp = isCaughtUp && lokiPoller.isCaughtUp(); } + if (lokiPublicChatManager != null) { + isCaughtUp = isCaughtUp && lokiPublicChatManager.areAllCaughtUp(); + } + if (isCaughtUp) { performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, threadId)); } else { @@ -74,9 +82,13 @@ public class OptimizedMessageNotifier implements MessageNotifier { public void updateNotification(@NonNull Context context, long threadId, boolean signal) { Poller lokiPoller = ApplicationContext.getInstance(context).lokiPoller; LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager; - boolean isCaughtUp = false; - if (lokiPoller != null && lokiPublicChatManager != null) { - isCaughtUp = lokiPoller.isCaughtUp() && lokiPublicChatManager.areAllCaughtUp(); + boolean isCaughtUp = true; + if (lokiPoller != null) { + isCaughtUp = isCaughtUp && lokiPoller.isCaughtUp(); + } + + if (lokiPublicChatManager != null) { + isCaughtUp = isCaughtUp && lokiPublicChatManager.areAllCaughtUp(); } if (isCaughtUp) { @@ -90,9 +102,13 @@ public class OptimizedMessageNotifier implements MessageNotifier { public void updateNotification(@android.support.annotation.NonNull Context context, boolean signal, int reminderCount) { Poller lokiPoller = ApplicationContext.getInstance(context).lokiPoller; LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager; - boolean isCaughtUp = false; - if (lokiPoller != null && lokiPublicChatManager != null) { - isCaughtUp = lokiPoller.isCaughtUp() && lokiPublicChatManager.areAllCaughtUp(); + boolean isCaughtUp = true; + if (lokiPoller != null) { + isCaughtUp = isCaughtUp && lokiPoller.isCaughtUp(); + } + + if (lokiPublicChatManager != null) { + isCaughtUp = isCaughtUp && lokiPublicChatManager.areAllCaughtUp(); } if (isCaughtUp) {