Skip to content

Commit

Permalink
Revert fix in MainViewModel & Fix possible issue in WebSearch plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack251970 committed Dec 8, 2024
1 parent 0c43ea9 commit 9a7c08b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
35 changes: 13 additions & 22 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,35 +1447,26 @@ public void UpdateResultView(ICollection<ResultsForUpdate> resultsForUpdates)
}
#endif

try
foreach (var metaResults in resultsForUpdates)
{
foreach (var metaResults in resultsForUpdates)
foreach (var result in metaResults.Results)
{
foreach (var result in metaResults.Results)
if (_topMostRecord.IsTopMost(result))
{
if (_topMostRecord.IsTopMost(result))
{
result.Score = int.MaxValue;
}
else
{
var priorityScore = metaResults.Metadata.Priority * 150;
result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore;
}
result.Score = int.MaxValue;
}
else
{
var priorityScore = metaResults.Metadata.Priority * 150;
result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore;
}
}
}

// it should be the same for all results
bool reSelect = resultsForUpdates.First().ReSelectFirstResult;
// it should be the same for all results
bool reSelect = resultsForUpdates.First().ReSelectFirstResult;

Results.AddResults(resultsForUpdates, token, reSelect);
}
catch (InvalidOperationException e)
{
// Plugin with IResultUpdate interface can somtimes throw this exception
// Collection was modified; enumeration operation may not execute
Log.Exception($"{nameof(MainViewModel)}.{nameof(UpdateResultView)}|UpdateResultView failed", e);
}
Results.AddResults(resultsForUpdates, token, reSelect);
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)

ResultsUpdated?.Invoke(this, new ResultUpdatedEventArgs
{
Results = results,
Results = results.ToList(),
Query = query
});

Expand Down

0 comments on commit 9a7c08b

Please sign in to comment.