From 50625868b28aa8b34d23bc11d1876833043c25be Mon Sep 17 00:00:00 2001 From: Tunous Date: Wed, 12 Apr 2017 22:55:11 +0200 Subject: [PATCH] Mark repository as read when marking last unread notification --- src/com/gh4a/adapter/NotificationAdapter.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/gh4a/adapter/NotificationAdapter.java b/src/com/gh4a/adapter/NotificationAdapter.java index 92763a8fa..34e8f3cba 100644 --- a/src/com/gh4a/adapter/NotificationAdapter.java +++ b/src/com/gh4a/adapter/NotificationAdapter.java @@ -48,7 +48,7 @@ public NotificationAdapter(Context context, OnNotificationActionCallback actionC public void markAsRead(@Nullable Repository repository, @Nullable Notification notification) { NotificationHolder previousRepoItem = null; - int notificationsInSameRepoCount = 0; + int unreadNotificationsInSameRepoCount = 0; boolean isMarkingSingleNotification = repository == null && notification != null; @@ -63,24 +63,24 @@ public void markAsRead(@Nullable Repository repository, @Nullable Notification n } // When marking single notification as read also mark the repository if it contained - // only 1 notification + // only 1 unread notification if (isMarkingSingleNotification) { if (item.notification == null) { - if (previousRepoItem != null && notificationsInSameRepoCount == 1 + if (previousRepoItem != null && unreadNotificationsInSameRepoCount == 0 && previousRepoItem.repository.equals(notification.getRepository())) { previousRepoItem.setIsRead(true); } previousRepoItem = item; - notificationsInSameRepoCount = 0; - } else { - notificationsInSameRepoCount += 1; + unreadNotificationsInSameRepoCount = 0; + } else if (!item.isRead()) { + unreadNotificationsInSameRepoCount += 1; } } } // Additional check for the very last notification if (isMarkingSingleNotification && previousRepoItem != null - && notificationsInSameRepoCount == 1 + && unreadNotificationsInSameRepoCount == 0 && previousRepoItem.repository.equals(notification.getRepository())) { previousRepoItem.setIsRead(true); }