From da8b6340aec8a900efa3326ff91fe317ec6e4cc3 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 22 Mar 2016 08:59:31 +0000 Subject: [PATCH] Fixed #74 and #64 --- .../Notification/NotificationService.cs | 3 --- PlexRequests.UI/Modules/AdminModule.cs | 21 +++++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/PlexRequests.Services/Notification/NotificationService.cs b/PlexRequests.Services/Notification/NotificationService.cs index 4ef7a8bd0..81968c28d 100644 --- a/PlexRequests.Services/Notification/NotificationService.cs +++ b/PlexRequests.Services/Notification/NotificationService.cs @@ -62,12 +62,9 @@ namespace PlexRequests.Services.Notification public static void Subscribe(INotification notification) { - Log.Trace("Subscribing Observer {0}", notification.NotificationName); INotification notificationValue; if (Observers.TryGetValue(notification.NotificationName, out notificationValue)) { - Log.Trace("Observer {0} already exists", notification.NotificationName); - // Observer already exists return; } diff --git a/PlexRequests.UI/Modules/AdminModule.cs b/PlexRequests.UI/Modules/AdminModule.cs index eeac628f0..900f3da35 100644 --- a/PlexRequests.UI/Modules/AdminModule.cs +++ b/PlexRequests.UI/Modules/AdminModule.cs @@ -356,8 +356,15 @@ namespace PlexRequests.UI.Modules Log.Trace(settings.DumpJson()); var result = EmailService.SaveSettings(settings); - - NotificationService.Subscribe(new EmailMessageNotification(EmailService)); + + if (settings.Enabled) + { + NotificationService.Subscribe(new EmailMessageNotification(EmailService)); + } + else + { + NotificationService.UnSubscribe(new EmailMessageNotification(EmailService)); + } Log.Info("Saved email settings, result: {0}", result); return Response.AsJson(result @@ -389,8 +396,14 @@ namespace PlexRequests.UI.Modules Log.Trace(settings.DumpJson()); var result = PushbulletService.SaveSettings(settings); - - NotificationService.Subscribe(new PushbulletNotification(PushbulletApi, PushbulletService)); + if (settings.Enabled) + { + NotificationService.Subscribe(new PushbulletNotification(PushbulletApi, PushbulletService)); + } + else + { + NotificationService.UnSubscribe(new PushbulletNotification(PushbulletApi, PushbulletService)); + } Log.Info("Saved email settings, result: {0}", result); return Response.AsJson(result