From 1e300807e4e4af072f5b5ef91b1a713e4e3b33be Mon Sep 17 00:00:00 2001 From: Michael Kirschner Date: Mon, 8 Mar 2021 14:06:24 -0500 Subject: [PATCH] set IsFirstRun to false if hide report options is true (#11530) * Update DynamoView.xaml.cs * add test add internal setter * review comments Co-authored-by: michael kirschner --- src/DynamoCoreWpf/Services/UsageReportingManager.cs | 8 ++++---- src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs | 2 +- src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs | 8 +++----- test/DynamoCoreWpfTests/CoreUITests.cs | 11 +++++++++++ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/DynamoCoreWpf/Services/UsageReportingManager.cs b/src/DynamoCoreWpf/Services/UsageReportingManager.cs index 19d7817beed..99664ead76e 100644 --- a/src/DynamoCoreWpf/Services/UsageReportingManager.cs +++ b/src/DynamoCoreWpf/Services/UsageReportingManager.cs @@ -146,14 +146,14 @@ public void CheckIsFirstRun(Window ownerWindow, IBrandingResourceProvider resour { resourceProvider = resource; // First run of Dynamo - if (dynamoViewModel.Model.PreferenceSettings.IsFirstRun) + if (dynamoViewModel.Model.PreferenceSettings.IsFirstRun + && !dynamoViewModel.HideReportOptions + && !DynamoModel.IsTestMode) { - FirstRun = false; - //Prompt user for detailed reporting - if (!DynamoModel.IsTestMode) ShowUsageReportingPrompt(ownerWindow); } + FirstRun = false; } [Obsolete("Function will be removed in Dynamo 3.0, please set IsUsageReportingApproved.")] diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index 181eeeff5d5..83f68be3e3d 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -503,7 +503,7 @@ public bool BackgroundPreviewActive get { return BackgroundPreviewViewModel.Active; } } - public bool HideReportOptions { get; } + public bool HideReportOptions { get; internal set; } /// /// Indicates if whether the Iron Python dialog box should be displayed before each new session. diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs index a4f8dfd9b39..11aed3d7e77 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs @@ -898,11 +898,9 @@ private void DynamoView_Loaded(object sender, EventArgs e) //Backing up IsFirstRun to determine whether to show Gallery var isFirstRun = dynamoViewModel.Model.PreferenceSettings.IsFirstRun; - if (!dynamoViewModel.HideReportOptions) - { - // If first run, Collect Info Prompt will appear - UsageReportingManager.Instance.CheckIsFirstRun(this, dynamoViewModel.BrandingResourceProvider); - } + // If first run, Collect Info Prompt will appear + UsageReportingManager.Instance.CheckIsFirstRun(this, dynamoViewModel.BrandingResourceProvider); + WorkspaceTabs.SelectedIndex = 0; dynamoViewModel = (DataContext as DynamoViewModel); diff --git a/test/DynamoCoreWpfTests/CoreUITests.cs b/test/DynamoCoreWpfTests/CoreUITests.cs index 2dc20cb61a5..8801c72eda0 100644 --- a/test/DynamoCoreWpfTests/CoreUITests.cs +++ b/test/DynamoCoreWpfTests/CoreUITests.cs @@ -666,6 +666,17 @@ public void PreferenceSettings_ShowEdges_Save() Assert.True(resultSetting.ShowEdges); } + [Test] + public void PreferenceSettings_IsFirstRun_And_HideReportOptions() + { + ViewModel.HideReportOptions = true; + ViewModel.Model.PreferenceSettings.IsFirstRun = true; + //force the dynamoview's loaded handler to be called again - + View.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); + + Assert.IsFalse(ViewModel.PreferenceSettings.IsFirstRun); + } + private void RestartTestSetup(bool startInTestMode) { // Shutdown Dynamo and restart it