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