Skip to content

Commit

Permalink
set IsFirstRun to false if hide report options is true (#11530) (#11535)
Browse files Browse the repository at this point in the history
* Update DynamoView.xaml.cs

* add test
add internal setter

* review comments

Co-authored-by: michael kirschner <[email protected]>

Co-authored-by: michael kirschner <[email protected]>
  • Loading branch information
mjkkirschner and mjkkirschner authored Mar 8, 2021
1 parent d486c97 commit b71ed4d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/DynamoCoreWpf/Services/UsageReportingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public bool BackgroundPreviewActive
get { return BackgroundPreviewViewModel.Active; }
}

public bool HideReportOptions { get; }
public bool HideReportOptions { get; internal set; }

/// <summary>
/// Indicates if whether the Iron Python dialog box should be displayed before each new session.
Expand Down
8 changes: 3 additions & 5 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions test/DynamoCoreWpfTests/CoreUITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b71ed4d

Please sign in to comment.