File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
sdk/Notifo.SDK/NotifoMobilePush Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -81,19 +81,29 @@ public async Task DidReceivePullRefreshRequestAsync(PullRefreshOptions? options
81
81
await TrackNotificationsAsync ( notifications . ToArray ( ) ) ;
82
82
}
83
83
84
- private async Task < IEnumerable < UserNotificationDto > > GetPendingNotificationsAsync ( int take , TimeSpan period )
84
+ private async Task < IEnumerable < UserNotificationDto > > GetPendingNotificationsAsync ( int take , TimeSpan maxAge )
85
85
{
86
86
try
87
87
{
88
88
var notificationPending = await Notifications . GetMyNotificationsAsync ( take : take ) ;
89
- var notificationSeen = await GetSeenNotificationsAsync ( ) ;
90
89
91
- var utcNow = DateTimeOffset . UtcNow ;
90
+ if ( notificationPending . Items . Count == 0 )
91
+ {
92
+ return Enumerable . Empty < UserNotificationDto > ( ) ;
93
+ }
94
+
95
+ var currentSeen = await GetSeenNotificationsAsync ( ) ;
96
+ var currentTime = DateTimeOffset . UtcNow ;
97
+
98
+ bool IsRecent ( DateTimeOffset date )
99
+ {
100
+ return ( currentTime - date . UtcDateTime ) <= maxAge ;
101
+ }
92
102
93
- var pendingNotifications = notificationPending
94
- . Items
95
- . Where ( x => ! notificationSeen . Contains ( x . Id ) )
96
- . Where ( x => ( utcNow - x . Created . UtcDateTime ) <= period )
103
+ var pendingNotifications = notificationPending . Items
104
+ . Where ( n => ! n . IsSeen )
105
+ . Where ( n => ! currentSeen . Contains ( n . Id ) )
106
+ . Where ( n => IsRecent ( n . Created ) )
97
107
. OrderBy ( x => x . Created )
98
108
. ToArray ( ) ;
99
109
You can’t perform that action at this time.
0 commit comments