-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable Network Traffice When Notification Center Disabled #13286
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<object[]> onMarkAllAsRead; | ||
|
||
internal scriptObject(Action<object []> onMarkAllAsRead) | ||
internal ScriptObject(Action<object []> 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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I know the RequestNotifications(); only populates the number of notifications in the bell icon but this won't prevent that the webapp consume the REST API (not sure if that is the expected behavior). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RobertGlobant20 This will prevent Dynamo making the REST API calls, do you mean the WebApp will still do it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about simply not loading the extension? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @QilongTang if the objective is to prevent just Dynamo to make REST API calls then is OK but if you want also to prevent those calls in the WebApp then is a different story. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RobertGlobant20 @mjkkirschner My understanding is that the latest version of Notification Center is using process.env to control the endpoint and REST API calls will be made depending on if the endpoint address exist or not. When consumed by Dynamo, the end point is empty. I believe @filipeotero made such change so when used in Dynamo, the WebApp itself should not pull anything but rely on info passed by Dynamo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @filipeotero Please let me know if my understanding is correct. If not, then happy to follow up There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @QilongTang You are correct. The webApp itself will not request notifications if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's correct. In Dynamo, the notification center is waiting to push the notifications. Executing the notification center in development mode will grab the notifications by itself. |
||
} | ||
} | ||
|
||
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)); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a name vialation, I think in C# public class are all capitalized