@@ -485,7 +485,8 @@ class NotificationsViewModel @Inject constructor(
485485 }
486486
487487 // Status id -> (highest) Notification id
488- val seenFavorites = HashMap <String , String >()
488+ private val seenFavorites = HashMap <String , String >()
489+ private val seenBoosts = HashMap <String , String >()
489490
490491 private fun getNotifications (
491492 filters : Set <Notification .Type >,
@@ -498,10 +499,9 @@ class NotificationsViewModel @Inject constructor(
498499 ? : return @filter true
499500
500501 return @filter if (hasNewestNotificationId(notification.type, status.id, notification.id)) {
501- seenFavorites[status.id] = notification.id // TODO move to hasNewestNotificationId?
502-
503502 true
504503 } else {
504+ Log .d(TAG , " Filtering notification for " + status.id+ " at " + status.createdAt)
505505 false
506506 }
507507 }
@@ -517,13 +517,25 @@ class NotificationsViewModel @Inject constructor(
517517 }
518518
519519 fun hasNewestNotificationId (type : Notification .Type , statusId : String , notificationId : String ): Boolean {
520- if (type != Notification .Type .FAVOURITE ) {
521- return true
522- }
520+ val trackerArray = when (type) {
521+ Notification .Type .FAVOURITE -> seenFavorites
522+ Notification .Type .REBLOG -> seenBoosts
523+ else -> null
524+ } ? : return true
525+
526+ val highestNotificationId = trackerArray[statusId]
523527
524- val highestNotificationId = seenFavorites[statusId]
528+ return if (highestNotificationId == null || isEqualOrNewer(notificationId, highestNotificationId)) {
529+ trackerArray[statusId] = notificationId
525530
526- return highestNotificationId == null || isEqualOrNewer(notificationId, highestNotificationId)
531+ true
532+ } else {
533+ // TODO edge case: a newer favorite has been removed: the old notification will not be added again
534+ // (because the removed id is still in the seen array)
535+ // The code could find this out only heuristically: "looking at these notification ids (range), one in the array is not amongst them"
536+
537+ false
538+ }
527539 }
528540
529541 /* *
0 commit comments