From b5e401f759d01a9aa4d52a2500e5be15772b6480 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 23 Dec 2024 15:50:52 +0800 Subject: [PATCH 1/4] Fix user result set max value issue --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 7260593dc28..8bfd2f4e569 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1473,7 +1473,7 @@ public void UpdateResultView(ICollection resultsForUpdates) { result.Score = int.MaxValue; } - else + else if (result.Score != int.MaxValue) { var priorityScore = metaResults.Metadata.Priority * 150; result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore; From 4ad967b5f31c5e500d8ff08b5a897806c9890daa Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 23 Dec 2024 15:57:59 +0800 Subject: [PATCH 2/4] Add support for removing selected count from score --- Flow.Launcher.Plugin/Result.cs | 5 +++++ Flow.Launcher/ViewModel/MainViewModel.cs | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index 027631533a1..57ee1e92182 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -263,6 +263,11 @@ public ValueTask ExecuteAsync(ActionContext context) /// public PreviewInfo Preview { get; set; } = PreviewInfo.Default; + /// + /// Determines if the selected count should be added to the score + /// + public bool AddSelectedCount { get; set; } = true; + /// /// Info of the preview section of a /// diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 8bfd2f4e569..6458316bbb5 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1476,7 +1476,9 @@ public void UpdateResultView(ICollection resultsForUpdates) else if (result.Score != int.MaxValue) { var priorityScore = metaResults.Metadata.Priority * 150; - result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore; + result.Score += result.AddSelectedCount ? + _userSelectedRecord.GetSelectedCount(result) + priorityScore : + priorityScore; } } } From 1c01fa4e46a53367a3d0c66cc3fe3214e22bdcce Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 24 Dec 2024 14:32:05 +1100 Subject: [PATCH 3/4] update comment --- Flow.Launcher.Plugin/Result.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index 57ee1e92182..669927072d8 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -264,7 +264,7 @@ public ValueTask ExecuteAsync(ActionContext context) public PreviewInfo Preview { get; set; } = PreviewInfo.Default; /// - /// Determines if the selected count should be added to the score + /// 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. /// public bool AddSelectedCount { get; set; } = true; From 269e583ea7629c3b1bfd6bc945c39ac026bbe11d Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Tue, 24 Dec 2024 11:54:15 +0800 Subject: [PATCH 4/4] Add maximum score to the results for developers. --- Flow.Launcher.Plugin/Result.cs | 5 +++++ Flow.Launcher/ViewModel/MainViewModel.cs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index 669927072d8..f2050cc9f78 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -268,6 +268,11 @@ public ValueTask ExecuteAsync(ActionContext context) /// public bool AddSelectedCount { get; set; } = true; + /// + /// 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. + /// + public const int MaxScore = int.MaxValue; + /// /// Info of the preview section of a /// diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 6458316bbb5..e369a1fea15 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1471,9 +1471,9 @@ public void UpdateResultView(ICollection resultsForUpdates) { if (_topMostRecord.IsTopMost(result)) { - result.Score = int.MaxValue; + result.Score = Result.MaxScore; } - else if (result.Score != int.MaxValue) + else if (result.Score != Result.MaxScore) { var priorityScore = metaResults.Metadata.Priority * 150; result.Score += result.AddSelectedCount ?