private async void ReadNotifications(UserNotificationReader reader) { var notifications = await reader.ReadBatchAsync(UInt32.MaxValue); Logger.Instance.LogMessage($"Read {notifications.Count} notifications"); foreach (var notification in notifications) { //Logger.Instance.LogMessage($"UserNotification: {notification.Id} Status: {notification.Status} ReadState: {notification.ReadState} UserActionState: {notification.UserActionState}"); if (notification.Status == UserNotificationStatus.Active) { m_newNotifications.RemoveAll((n) => { return(n.Id == notification.Id); }); if (notification.UserActionState == UserNotificationUserActionState.NoInteraction) { // Brand new notification, add to new m_newNotifications.Add(notification); Logger.Instance.LogMessage($"UserNotification not interacted: {notification.Id}"); if (!string.IsNullOrEmpty(notification.Content) && notification.ReadState != UserNotificationReadState.Read) { RemoveToastNotification(notification.Id); ShowToastNotification(BuildToastNotification(notification.Id, notification.Content)); } } else { RemoveToastNotification(notification.Id); } m_historicalNotifications.RemoveAll((n) => { return(n.Id == notification.Id); }); m_historicalNotifications.Insert(0, notification); } else { // Historical notification is marked as deleted, remove from display m_newNotifications.RemoveAll((n) => { return(n.Id == notification.Id); }); m_historicalNotifications.RemoveAll((n) => { return(n.Id == notification.Id); }); RemoveToastNotification(notification.Id); } } CacheUpdated?.Invoke(this, new EventArgs()); }