From f4dd80c9298ce0ff5c368ca84f6ce5f97a3c7dcb Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Tue, 15 Jun 2021 13:09:11 -0400 Subject: [PATCH] Switch logic order for detecting conversation channel changes. --- .../notifications/NotificationChannels.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java index efbcb1e8f6..13b572eb8a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java @@ -550,12 +550,9 @@ public class NotificationChannels { Set existingChannelIds = Stream.of(notificationManager.getNotificationChannels()).map(NotificationChannel::getId).collect(Collectors.toSet()); for (NotificationChannel existingChannel : notificationManager.getNotificationChannels()) { - if (existingChannel.getId().startsWith(CONTACT_PREFIX) && !customChannelIds.contains(existingChannel.getId())) { - Log.i(TAG, "Consistency: Deleting channel '"+ existingChannel.getId() + "' because the DB has no record of it."); - notificationManager.deleteNotificationChannel(existingChannel.getId()); - } else if (existingChannel.getId().startsWith(MESSAGES_PREFIX) && - Build.VERSION.SDK_INT >= CONVERSATION_SUPPORT_VERSION && - existingChannel.getConversationId() != null) + if ((existingChannel.getId().startsWith(CONTACT_PREFIX) || existingChannel.getId().startsWith(MESSAGES_PREFIX)) && + Build.VERSION.SDK_INT >= CONVERSATION_SUPPORT_VERSION && + existingChannel.getConversationId() != null) { if (customChannelIds.contains(existingChannel.getId())) { continue; @@ -569,6 +566,9 @@ public class NotificationChannels { Log.i(TAG, "Consistency: Conversation channel created outside of app with no matching recipient, deleting channel '" + existingChannel.getId() + "'"); notificationManager.deleteNotificationChannel(existingChannel.getId()); } + } else if (existingChannel.getId().startsWith(CONTACT_PREFIX) && !customChannelIds.contains(existingChannel.getId())) { + Log.i(TAG, "Consistency: Deleting channel '"+ existingChannel.getId() + "' because the DB has no record of it."); + notificationManager.deleteNotificationChannel(existingChannel.getId()); } else if (existingChannel.getId().startsWith(MESSAGES_PREFIX) && !existingChannel.getId().equals(getMessagesChannel(context))) { Log.i(TAG, "Consistency: Deleting channel '" + existingChannel.getId() + "' because it's out of date."); notificationManager.deleteNotificationChannel(existingChannel.getId());