Skip to content
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

Add options for setting result on top & keeping result order #3144

Merged
merged 4 commits into from
Dec 24, 2024
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
10 changes: 10 additions & 0 deletions Flow.Launcher.Plugin/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ public ValueTask<bool> ExecuteAsync(ActionContext context)
/// </summary>
public PreviewInfo Preview { get; set; } = PreviewInfo.Default;

/// <summary>
/// Determines if the user selection count should be added to the score. This can be useful when set to false to allow the result sequence order to be the same everytime instead of changing based on selection.
/// </summary>
public bool AddSelectedCount { get; set; } = true;

/// <summary>
/// Maximum score. This can be useful when set one result to the top by default. This is the score for the results set to the topmost by users.
/// </summary>
public const int MaxScore = int.MaxValue;

/// <summary>
/// Info of the preview section of a <see cref="Result"/>
/// </summary>
Expand Down
8 changes: 5 additions & 3 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1471,12 +1471,14 @@ public void UpdateResultView(ICollection<ResultsForUpdate> resultsForUpdates)
{
if (_topMostRecord.IsTopMost(result))
{
result.Score = int.MaxValue;
result.Score = Result.MaxScore;
}
else
else if (result.Score != Result.MaxScore)
{
var priorityScore = metaResults.Metadata.Priority * 150;
result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore;
result.Score += result.AddSelectedCount ?
_userSelectedRecord.GetSelectedCount(result) + priorityScore :
priorityScore;
}
}
}
Expand Down
Loading