diff --git a/src/Notifications/NotificationCenterController.cs b/src/Notifications/NotificationCenterController.cs index a9f3a839b65..491a2020ced 100644 --- a/src/Notifications/NotificationCenterController.cs +++ b/src/Notifications/NotificationCenterController.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Collections.Generic; -using System.Configuration; using System.IO; using System.Linq; using System.Net; @@ -11,7 +9,6 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; -using Dynamo.Configuration; using Dynamo.Controls; using Dynamo.Logging; using Dynamo.Notifications.View; @@ -23,11 +20,11 @@ namespace Dynamo.Notifications { [ClassInterface(ClassInterfaceType.AutoDual)] [ComVisible(true)] - public class scriptObject + public class ScriptObject { Action onMarkAllAsRead; - internal scriptObject(Action onMarkAllAsRead) + internal ScriptObject(Action onMarkAllAsRead) { this.onMarkAllAsRead = onMarkAllAsRead; } @@ -53,7 +50,7 @@ public class NotificationCenterController private static readonly string jsEmbeddedFile = "Dynamo.Notifications.node_modules._dynamods.notifications_center.build.index.bundle.js"; private static readonly string NotificationCenterButtonName = "notificationsButton"; - private DynamoLogger logger; + private readonly DynamoLogger logger; private string jsonStringFile; private NotificationsModel notificationsModel; @@ -78,8 +75,12 @@ internal NotificationCenterController(DynamoView view, DynamoLogger dynLogger) notificationUIPopup.webView.EnsureCoreWebView2Async(); notificationUIPopup.webView.CoreWebView2InitializationCompleted += WebView_CoreWebView2InitializationCompleted; logger = dynLogger; - - RequestNotifications(); + // If user turns on the feature, they will need to restart Dynamo to see the count + // This ensures no network traffic when Notification center feature is turned off + if (dynamoViewModel.PreferenceSettings.EnableNotificationCenter) + { + RequestNotifications(); + } } private void WebView_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e) @@ -177,7 +178,7 @@ private void WebView_CoreWebView2InitializationCompleted(object sender, Microsof notificationUIPopup.webView.CoreWebView2.NavigateToString(htmlString); // Hosts an object that will expose the properties and methods to be called from the javascript side notificationUIPopup.webView.CoreWebView2.AddHostObjectToScript("scriptObject", - new scriptObject(OnMarkAllAsRead)); + new ScriptObject(OnMarkAllAsRead)); } }