@@ -551,6 +551,7 @@ public class LootLockerListNotificationsResponse : LootLockerResponse
551
551
/// Pagination data for this set of notifications
552
552
/// </summary>
553
553
public LootLockerExtendedPagination Pagination { get ; set ; }
554
+
554
555
/// <summary>
555
556
/// Will mark all unread notifications in this response as read in LootLocker (though remember to check the response if it succeeded)
556
557
/// </summary>
@@ -578,21 +579,25 @@ public void MarkUnreadNotificationsAsRead(Action<LootLockerReadNotificationsResp
578
579
public bool TryGetNotificationsByIdentifyingValue ( string identifyingValue , out LootLockerNotification [ ] notifications )
579
580
{
580
581
notifications = null ;
581
- if ( ! NotificationLookupTable . TryGetValue ( identifyingValue , out var indexes ) )
582
+ if ( ! NotificationLookupTable . TryGetValue ( identifyingValue , out var lookupEntries ) )
582
583
{
583
584
return false ;
584
585
}
585
586
586
587
var foundNotifications = new List < LootLockerNotification > ( ) ;
587
- foreach ( var index in indexes )
588
+ foreach ( var lookupEntry in lookupEntries )
588
589
{
589
- if ( index < 0 || index >= Notifications . Length )
590
+ if ( lookupEntry . NotificationIndex < 0 || lookupEntry . NotificationIndex >= Notifications . Length )
590
591
{
591
592
// The notifications array is not the same as when the lookup table was populated
592
593
return false ;
593
594
}
594
- var notification = Notifications [ index ] ;
595
- if ( ! notification . Content . ContextAsDictionary . ContainsValue ( identifyingValue ) )
595
+ var notification = Notifications [ lookupEntry . NotificationIndex ] ;
596
+ if ( notification == null
597
+ || ! notification . Id . Equals ( lookupEntry . NotificationId , StringComparison . OrdinalIgnoreCase )
598
+ || ! notification . Content . ContextAsDictionary . TryGetValue ( lookupEntry . IdentifyingKey , out string actualContextValue )
599
+ || actualContextValue == null
600
+ || ! actualContextValue . Equals ( identifyingValue , StringComparison . OrdinalIgnoreCase ) )
596
601
{
597
602
// The notifications array is not the same as when the lookup table was populated
598
603
return false ;
@@ -647,21 +652,36 @@ public void PopulateConvenienceStructures()
647
652
648
653
if ( identifyingKey != null && notification . Content . ContextAsDictionary . TryGetValue ( identifyingKey , out var value ) && value != null )
649
654
{
655
+ var lookupEntry = new LootLockerNotificationLookupTableEntry
656
+ {
657
+ IdentifyingKey = identifyingKey ,
658
+ NotificationId = notification . Id ,
659
+ NotificationIndex = i
660
+ } ;
650
661
if ( NotificationLookupTable . TryGetValue ( value , out var indexes ) )
651
662
{
652
- indexes . Add ( i ) ;
663
+ indexes . Add ( lookupEntry ) ;
653
664
}
654
665
else
655
666
{
656
- NotificationLookupTable . Add ( value , new List < int > { i } ) ;
667
+ NotificationLookupTable . Add ( value , new List < LootLockerNotificationLookupTableEntry > { lookupEntry } ) ;
657
668
}
658
669
}
659
670
++ i ;
660
671
}
661
672
}
662
673
663
674
private readonly List < string > UnreadNotifications = new List < string > ( ) ;
664
- private readonly Dictionary < string , List < int > > NotificationLookupTable = new Dictionary < string , List < int > > ( ) ;
675
+
676
+ /// <summary>
677
+ /// </summary>
678
+ private struct LootLockerNotificationLookupTableEntry
679
+ {
680
+ public string IdentifyingKey { get ; set ; }
681
+ public string NotificationId { get ; set ; }
682
+ public int NotificationIndex { get ; set ; }
683
+ } ;
684
+ private readonly Dictionary < string , List < LootLockerNotificationLookupTableEntry > > NotificationLookupTable = new Dictionary < string , List < LootLockerNotificationLookupTableEntry > > ( ) ;
665
685
} ;
666
686
667
687
/// <summary>
0 commit comments