diff --git a/ArchiSteamFarm/ArchiHandler.cs b/ArchiSteamFarm/ArchiHandler.cs index d50d7eccf..d255a0227 100644 --- a/ArchiSteamFarm/ArchiHandler.cs +++ b/ArchiSteamFarm/ArchiHandler.cs @@ -261,20 +261,25 @@ namespace ArchiSteamFarm { JobID = jobID; - if (msg.notifications.Count == 0) { - return; - } + // We might get null body here, and that means there are no notifications related to trading + Dictionary notificationsMap = new Dictionary(1) { + { ENotification.Trading, 0 } + }; - Notifications = new HashSet(); + if (msg.notifications != null) { + foreach (CMsgClientUserNotifications.Notification notification in msg.notifications) { + ENotification type = (ENotification) notification.user_notification_type; - foreach (CMsgClientUserNotifications.Notification notification in msg.notifications) { - if (notification.user_notification_type == 0) { - ASF.ArchiLogger.LogNullError(nameof(notification.user_notification_type)); - continue; + if (type == ENotification.Unknown) { + ASF.ArchiLogger.LogNullError(nameof(notification.user_notification_type)); + continue; + } + + notificationsMap[type] = notification.count; } - - Notifications.Add(new Notification((ENotification) notification.user_notification_type, notification.count)); } + + Notifications = new HashSet(notificationsMap.Select(kv => new Notification(kv.Key, kv.Value))); } internal NotificationsCallback(JobID jobID, CMsgClientItemAnnouncements msg) {