From e3bc01bc440349fd1a73c844764d75ce307e361e Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 18 Nov 2017 20:35:57 +0100 Subject: [PATCH] Follow-up bugfix to https://github.com/JustArchi/ArchiSteamFarm/commit/2d767c41aacb33dda35a98fa4b41efb7d33f5ffe --- ArchiSteamFarm/ArchiHandler.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) 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) {