From 0f8932e7125a7911c8e6062bef133ae4c32cd4b8 Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 9 Jul 2023 21:38:49 +0200 Subject: [PATCH] Fixed missing logger for notificationManagers on deserialization --- Tranga/NotificationManager.cs | 7 ++++++- Tranga/TrangaSettings.cs | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Tranga/NotificationManager.cs b/Tranga/NotificationManager.cs index 65ad36d..1c6da52 100644 --- a/Tranga/NotificationManager.cs +++ b/Tranga/NotificationManager.cs @@ -7,7 +7,7 @@ namespace Tranga; public abstract class NotificationManager { - protected readonly Logger? logger; + protected Logger? logger; public NotificationManagerType notificationManagerType; protected NotificationManager(NotificationManagerType notificationManagerType, Logger? logger = null) @@ -19,6 +19,11 @@ public abstract class NotificationManager public enum NotificationManagerType : byte { Gotify = 0, LunaSea = 1 } public abstract void SendNotification(string title, string notificationText); + + public void AddLogger(Logger pLogger) + { + this.logger = pLogger; + } public class NotificationManagerJsonConverter : JsonConverter { diff --git a/Tranga/TrangaSettings.cs b/Tranga/TrangaSettings.cs index e26218c..086dad5 100644 --- a/Tranga/TrangaSettings.cs +++ b/Tranga/TrangaSettings.cs @@ -37,8 +37,12 @@ public class TrangaSettings TrangaSettings settings = JsonConvert.DeserializeObject(toRead, new JsonSerializerSettings { Converters = { new NotificationManager.NotificationManagerJsonConverter(), new LibraryManager.LibraryManagerJsonConverter() } })!; if (logger is not null) + { foreach (LibraryManager lm in settings.libraryManagers) lm.AddLogger(logger); + foreach(NotificationManager nm in settings.notificationManagers) + nm.AddLogger(logger); + } return settings; }