Fixed missing logger for notificationManagers on deserialization
This commit is contained in:
parent
78023ef0fd
commit
0f8932e712
@ -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
|
||||
{
|
||||
|
@ -37,8 +37,12 @@ public class TrangaSettings
|
||||
TrangaSettings settings = JsonConvert.DeserializeObject<TrangaSettings>(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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user