Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ internal void OnShowNodeAutoCompleteSearch()
ViewModel.ResetAutoCompleteSearchViewState();
Dispatcher.BeginInvoke(new Action(() =>
{
SearchTextBox?.Focus();
ViewModel?.PopulateAutoCompleteCandidates();
ViewModel?.PopulateAutoCompleteCandidates(()=>SearchTextBox?.Focus());
}), DispatcherPriority.Loaded);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ internal MLNodeAutoCompletionRequest GenerateRequestForMLAutocomplete()
return request;
}

internal void ShowNodeAutocompleMLResults()
internal void ShowNodeAutocompleMLResults(Action? afterLoaded)
{
//this should run on the UI thread, so thread safety is not a concern
LastRequestGuid = Guid.NewGuid();
Expand All @@ -326,24 +326,25 @@ internal void ShowNodeAutocompleMLResults()
try
{
MLresults = GetMLNodeAutocompleteResults(jsonRequest);
this.dynamoViewModel.UIDispatcher.BeginInvoke(() => UpdateUIWithRresults(MLresults, myRequest));
this.dynamoViewModel.UIDispatcher.BeginInvoke(() => UpdateUIWithRresults(MLresults, myRequest, afterLoaded));
}
catch (Exception ex)
{
this.dynamoViewModel.UIDispatcher.BeginInvoke(() =>
{
if (LastRequestGuid != myRequest || !IsOpen) return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! You added this one as well. Nice!

ResultsLoaded = true; //fail gracefully
afterLoaded?.Invoke();
dynamoViewModel.Model.Logger.Log("Unable to fetch ML Node autocomplete results: " + ex.Message);
DisplayAutocompleteMLStaticPage = true;
AutocompleteMLTitle = Resources.LoginNeededTitle;
AutocompleteMLMessage = Resources.LoginNeededMessage;
Analytics.TrackEvent(Actions.View, Categories.NodeAutoCompleteOperations, "UnabletoFetch");
return;
});
}
});
}
private void UpdateUIWithRresults(MLNodeAutoCompletionResponse MLresults, Guid myRequest)
private void UpdateUIWithRresults(MLNodeAutoCompletionResponse MLresults, Guid myRequest, Action? afterLoaded)
{
if (LastRequestGuid != myRequest)
{
Expand All @@ -358,6 +359,7 @@ private void UpdateUIWithRresults(MLNodeAutoCompletionResponse MLresults, Guid m
return;
}
ResultsLoaded = true;
afterLoaded?.Invoke();
// no results
if (MLresults == null || MLresults.Results.Count() == 0)
{
Expand Down Expand Up @@ -455,6 +457,9 @@ private void UpdateUIWithRresults(MLNodeAutoCompletionResponse MLresults, Guid m

OrganizeConfidenceSection(results);
}

// Save the filtered results for search.
searchElementsCache = FilteredResults.ToList();
}

/// <summary>
Expand Down Expand Up @@ -588,15 +593,15 @@ internal HostNames GetHostNameEnum(string HostName)
/// <summary>
/// Key function to populate node autocomplete results to display
/// </summary>
internal void PopulateAutoCompleteCandidates()
internal void PopulateAutoCompleteCandidates(Action afterLoaded = null)
{
if (PortViewModel == null) return;

ResetAutoCompleteSearchViewState();

if (IsDisplayingMLRecommendation)
{
ShowNodeAutocompleMLResults();
ShowNodeAutocompleMLResults(afterLoaded);
//Tracking Analytics when raising Node Autocomplete with the Recommended Nodes option selected (Machine Learning)
Analytics.TrackEvent(
Actions.Show,
Expand All @@ -622,10 +627,9 @@ internal void PopulateAutoCompleteCandidates()
{
FilteredResults = GetViewModelForNodeSearchElements(objectTypeMatchingElements);
}
// Save the filtered results for search.
searchElementsCache = FilteredResults.ToList();
}

// Save the filtered results for search.
searchElementsCache = FilteredResults.ToList();
}

internal void PopulateDefaultAutoCompleteCandidates()
Expand Down
Loading