From caabf4c1bf204153638d6e8fb199ce4514549721 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Fri, 10 Jul 2020 15:36:23 +1000 Subject: [PATCH] fix logic error of isCaughtUp --- .../OptimizedMessageNotifier.java | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/org/thoughtcrime/securesms/notifications/OptimizedMessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/OptimizedMessageNotifier.java index eada9a49e8..a04a333f0a 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) { LokiPoller 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) { LokiPoller 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) { LokiPoller 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) { LokiPoller 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) {