From 129169e0a9372053529067d760c55ddad9b642d8 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 27 Nov 2024 19:33:33 +0800 Subject: [PATCH 01/12] Fix possible null reference when query is cancelled --- Flow.Launcher/Storage/TopMostRecord.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/Storage/TopMostRecord.cs b/Flow.Launcher/Storage/TopMostRecord.cs index 052c296cdde..50ce96dedd8 100644 --- a/Flow.Launcher/Storage/TopMostRecord.cs +++ b/Flow.Launcher/Storage/TopMostRecord.cs @@ -12,7 +12,7 @@ public class TopMostRecord internal bool IsTopMost(Result result) { - if (records.Count == 0 || !records.ContainsKey(result.OriginQuery.RawQuery)) + if (records.Count == 0 || (result.OriginQuery != null && !records.ContainsKey(result.OriginQuery.RawQuery))) { return false; } From a8d69c7dd98aae982a44dcc06dcd82d65753a739 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 27 Nov 2024 19:34:34 +0800 Subject: [PATCH 02/12] Add support when image format is not support --- Flow.Launcher.Infrastructure/Image/ImageLoader.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index 612f495be64..c5bba9fedb3 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -215,8 +215,15 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag type = ImageType.ImageFile; if (loadFullImage) { - image = LoadFullImage(path); - type = ImageType.FullImageFile; + try + { + image = LoadFullImage(path); + type = ImageType.FullImageFile; + } + catch (NotSupportedException) + { + image = null; + } } else { @@ -242,7 +249,7 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag if (type != ImageType.Error) { - image.Freeze(); + image?.Freeze(); } return new ImageResult(image, type); From 756e718775c479658bd8a233430167c7460c810a Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 27 Nov 2024 19:46:30 +0800 Subject: [PATCH 03/12] Regard format not support files as error type --- Flow.Launcher.Infrastructure/Image/ImageLoader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index c5bba9fedb3..4592269a254 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -223,6 +223,7 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag catch (NotSupportedException) { image = null; + type = ImageType.Error; } } else @@ -249,7 +250,7 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag if (type != ImageType.Error) { - image?.Freeze(); + image.Freeze(); } return new ImageResult(image, type); From 0720779c6b0632eb7f8ac26e78b1f28b5f1e5569 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 27 Nov 2024 20:19:31 +0800 Subject: [PATCH 04/12] Fix possible null reference when query is cancelled --- Flow.Launcher/Storage/TopMostRecord.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/Storage/TopMostRecord.cs b/Flow.Launcher/Storage/TopMostRecord.cs index 50ce96dedd8..a088353f594 100644 --- a/Flow.Launcher/Storage/TopMostRecord.cs +++ b/Flow.Launcher/Storage/TopMostRecord.cs @@ -18,7 +18,7 @@ internal bool IsTopMost(Result result) } // since this dictionary should be very small (or empty) going over it should be pretty fast. - return records[result.OriginQuery.RawQuery].Equals(result); + return result.OriginQuery != null && records[result.OriginQuery.RawQuery].Equals(result); } internal void Remove(Result result) From b95bbb3e6a2ce2e384f874e381b9ff0190f00c57 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 27 Nov 2024 20:56:14 +0800 Subject: [PATCH 05/12] Introduce concurrent directionary for topmost record --- Flow.Launcher/Storage/TopMostRecord.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher/Storage/TopMostRecord.cs b/Flow.Launcher/Storage/TopMostRecord.cs index a088353f594..069b670cbc3 100644 --- a/Flow.Launcher/Storage/TopMostRecord.cs +++ b/Flow.Launcher/Storage/TopMostRecord.cs @@ -1,18 +1,18 @@ -using System.Collections.Generic; +using System.Collections.Concurrent; +using System.Collections.Generic; using System.Text.Json.Serialization; using Flow.Launcher.Plugin; namespace Flow.Launcher.Storage { - // todo this class is not thread safe.... but used from multiple threads. public class TopMostRecord { [JsonInclude] - public Dictionary records { get; private set; } = new Dictionary(); + public ConcurrentDictionary records { get; private set; } = new ConcurrentDictionary(); internal bool IsTopMost(Result result) { - if (records.Count == 0 || (result.OriginQuery != null && !records.ContainsKey(result.OriginQuery.RawQuery))) + if (records.IsEmpty || (result.OriginQuery != null && !records.ContainsKey(result.OriginQuery.RawQuery))) { return false; } @@ -23,7 +23,7 @@ internal bool IsTopMost(Result result) internal void Remove(Result result) { - records.Remove(result.OriginQuery.RawQuery); + records.Remove(result.OriginQuery.RawQuery, out _); } internal void AddOrUpdate(Result result) @@ -34,17 +34,15 @@ internal void AddOrUpdate(Result result) Title = result.Title, SubTitle = result.SubTitle }; - records[result.OriginQuery.RawQuery] = record; - + records.AddOrUpdate(result.OriginQuery.RawQuery, record, (key, oldValue) => record); } public void Load(Dictionary dictionary) { - records = dictionary; + records = new ConcurrentDictionary(dictionary); } } - public class Record { public string Title { get; set; } From c474b304f539e657b1d289575aa2b6244db47180 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 27 Nov 2024 21:21:42 +0800 Subject: [PATCH 06/12] Fix possible null reference --- Flow.Launcher/Storage/UserSelectedRecord.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/Storage/UserSelectedRecord.cs b/Flow.Launcher/Storage/UserSelectedRecord.cs index 6afe1e91f8d..d6405005dba 100644 --- a/Flow.Launcher/Storage/UserSelectedRecord.cs +++ b/Flow.Launcher/Storage/UserSelectedRecord.cs @@ -51,6 +51,11 @@ private static int GenerateResultHashCode(Result result) private static int GenerateQueryAndResultHashCode(Query query, Result result) { + if (query == null) + { + return GenerateResultHashCode(result); + } + int hashcode = GenerateStaticHashCode(query.ActionKeyword); hashcode = GenerateStaticHashCode(query.Search, hashcode); hashcode = GenerateStaticHashCode(result.Title, hashcode); @@ -101,4 +106,4 @@ public int GetSelectedCount(Result result) return selectedCount; } } -} \ No newline at end of file +} From d8c07a5741a6bde36e12e6aeb237af537274a80b Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 27 Nov 2024 21:44:44 +0800 Subject: [PATCH 07/12] Fix result update issue during modified collection enumeration --- Flow.Launcher/ViewModel/MainViewModel.cs | 35 ++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 6c17e21f0d2..f07d5c6dd96 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -1440,26 +1440,33 @@ public void UpdateResultView(ICollection resultsForUpdates) } #endif - foreach (var metaResults in resultsForUpdates) + try { - foreach (var result in metaResults.Results) + foreach (var metaResults in resultsForUpdates) { - if (_topMostRecord.IsTopMost(result)) - { - result.Score = int.MaxValue; - } - else + foreach (var result in metaResults.Results) { - var priorityScore = metaResults.Metadata.Priority * 150; - result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore; + if (_topMostRecord.IsTopMost(result)) + { + 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); + Results.AddResults(resultsForUpdates, token, reSelect); + } + catch (Exception ex) + { + Log.Debug("MainViewModel", $"Error in UpdateResultView: {ex.Message}"); + } } #endregion From c3c6126bab91b1e61fa951f8cf8a2dd902f81a19 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 27 Nov 2024 21:57:17 +0800 Subject: [PATCH 08/12] Fix xaml convert issue and use icon loader for PluginActivationIcon --- Flow.Launcher/MainWindow.xaml | 2 +- Flow.Launcher/ViewModel/MainViewModel.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index b9ad975345c..f5fd729d45b 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -308,7 +308,7 @@ VerticalAlignment="Center" Panel.ZIndex="2" RenderOptions.BitmapScalingMode="HighQuality" - Source="{Binding PluginIconPath}" + Source="{Binding PluginIconSource}" Stretch="Uniform" Style="{DynamicResource PluginActivationIcon}" /> diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index f07d5c6dd96..7b96e0cf3c1 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -23,6 +23,8 @@ using System.Globalization; using System.Windows.Input; using System.ComponentModel; +using Flow.Launcher.Infrastructure.Image; +using System.Windows.Media; namespace Flow.Launcher.ViewModel { @@ -722,6 +724,8 @@ public double ResultSubItemFontSize set => Settings.ResultSubItemFontSize = value; } + public ImageSource PluginIconSource { get; private set; } = null; + public string PluginIconPath { get; set; } = null; public string OpenResultCommandModifiers => Settings.OpenResultModifiers; @@ -1066,6 +1070,7 @@ private async void QueryResults(bool isReQuery = false, bool reSelect = true) Results.Clear(); Results.Visibility = Visibility.Collapsed; PluginIconPath = null; + PluginIconSource = null; SearchIconVisibility = Visibility.Visible; return; } @@ -1099,11 +1104,13 @@ private async void QueryResults(bool isReQuery = false, bool reSelect = true) if (plugins.Count == 1) { PluginIconPath = plugins.Single().Metadata.IcoPath; + PluginIconSource = await ImageLoader.LoadAsync(PluginIconPath); SearchIconVisibility = Visibility.Hidden; } else { PluginIconPath = null; + PluginIconSource = null; SearchIconVisibility = Visibility.Visible; } @@ -1467,6 +1474,8 @@ public void UpdateResultView(ICollection resultsForUpdates) { Log.Debug("MainViewModel", $"Error in UpdateResultView: {ex.Message}"); } + + } #endregion From c665482cb7684cbd40fa067aeb2d010185c0324f Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 2 Dec 2024 13:10:46 +0800 Subject: [PATCH 09/12] Improve code quality --- Flow.Launcher/Storage/TopMostRecord.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/Storage/TopMostRecord.cs b/Flow.Launcher/Storage/TopMostRecord.cs index 069b670cbc3..cbd0b88fc7e 100644 --- a/Flow.Launcher/Storage/TopMostRecord.cs +++ b/Flow.Launcher/Storage/TopMostRecord.cs @@ -12,13 +12,14 @@ public class TopMostRecord internal bool IsTopMost(Result result) { - if (records.IsEmpty || (result.OriginQuery != null && !records.ContainsKey(result.OriginQuery.RawQuery))) + if (records.IsEmpty || result.OriginQuery == null || + !records.TryGetValue(result.OriginQuery.RawQuery, out var value)) { return false; } // since this dictionary should be very small (or empty) going over it should be pretty fast. - return result.OriginQuery != null && records[result.OriginQuery.RawQuery].Equals(result); + return value.Equals(result); } internal void Remove(Result result) From 4830988c555815e7ccbc40ef2f4bfb4a292a942f Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 2 Dec 2024 13:54:07 +0800 Subject: [PATCH 10/12] Add image for format not supported images --- Flow.Launcher.Infrastructure/Constant.cs | 1 + .../Image/ImageLoader.cs | 3 ++- Flow.Launcher/Images/no_image.png | Bin 0 -> 2051 bytes 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Flow.Launcher/Images/no_image.png diff --git a/Flow.Launcher.Infrastructure/Constant.cs b/Flow.Launcher.Infrastructure/Constant.cs index 8a95ee79f77..c22355495de 100644 --- a/Flow.Launcher.Infrastructure/Constant.cs +++ b/Flow.Launcher.Infrastructure/Constant.cs @@ -31,6 +31,7 @@ public static class Constant public static readonly string ErrorIcon = Path.Combine(ImagesDirectory, "app_error.png"); public static readonly string MissingImgIcon = Path.Combine(ImagesDirectory, "app_missing_img.png"); public static readonly string LoadingImgIcon = Path.Combine(ImagesDirectory, "loading.png"); + public static readonly string NoImageIcon = Path.Combine(ImagesDirectory, "no_image.png"); public static string PythonPath; public static string NodePath; diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index 4592269a254..10c769ca611 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -22,6 +22,7 @@ public static class ImageLoader private static readonly ConcurrentDictionary GuidToKey = new(); private static IImageHashGenerator _hashGenerator; private static readonly bool EnableImageHash = true; + public static ImageSource NoImage { get; } = new BitmapImage(new Uri(Constant.NoImageIcon)); public static ImageSource MissingImage { get; } = new BitmapImage(new Uri(Constant.MissingImgIcon)); public static ImageSource LoadingImage { get; } = new BitmapImage(new Uri(Constant.LoadingImgIcon)); public const int SmallIconSize = 64; @@ -222,7 +223,7 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag } catch (NotSupportedException) { - image = null; + image = NoImage; type = ImageType.Error; } } diff --git a/Flow.Launcher/Images/no_image.png b/Flow.Launcher/Images/no_image.png new file mode 100644 index 0000000000000000000000000000000000000000..f8608727beb99f3445488002873532a82030762b GIT binary patch literal 2051 zcmV+e2>kb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*Ncz7n*NWfSisn@@XSv9{bLA|FK)K?Z?LOOUT_T`)w;l8)Vc5OTQy=U9e?-S%+uzfdETMED;+^ItufmKEZzq4c;Z+2Z`2o#Gv zQ Date: Tue, 3 Dec 2024 14:07:56 +0800 Subject: [PATCH 11/12] Update image for format not supported images --- Flow.Launcher.Infrastructure/Constant.cs | 2 +- .../Image/ImageLoader.cs | 4 ++-- Flow.Launcher/Images/image.png | Bin 687 -> 1122 bytes Flow.Launcher/Images/no_image.png | Bin 2051 -> 0 bytes 4 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 Flow.Launcher/Images/no_image.png diff --git a/Flow.Launcher.Infrastructure/Constant.cs b/Flow.Launcher.Infrastructure/Constant.cs index c22355495de..2889e5ec7ed 100644 --- a/Flow.Launcher.Infrastructure/Constant.cs +++ b/Flow.Launcher.Infrastructure/Constant.cs @@ -31,7 +31,7 @@ public static class Constant public static readonly string ErrorIcon = Path.Combine(ImagesDirectory, "app_error.png"); public static readonly string MissingImgIcon = Path.Combine(ImagesDirectory, "app_missing_img.png"); public static readonly string LoadingImgIcon = Path.Combine(ImagesDirectory, "loading.png"); - public static readonly string NoImageIcon = Path.Combine(ImagesDirectory, "no_image.png"); + public static readonly string ImageIcon = Path.Combine(ImagesDirectory, "image.png"); public static string PythonPath; public static string NodePath; diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index 10c769ca611..018c4f7c9e6 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -22,7 +22,7 @@ public static class ImageLoader private static readonly ConcurrentDictionary GuidToKey = new(); private static IImageHashGenerator _hashGenerator; private static readonly bool EnableImageHash = true; - public static ImageSource NoImage { get; } = new BitmapImage(new Uri(Constant.NoImageIcon)); + public static ImageSource Image { get; } = new BitmapImage(new Uri(Constant.ImageIcon)); public static ImageSource MissingImage { get; } = new BitmapImage(new Uri(Constant.MissingImgIcon)); public static ImageSource LoadingImage { get; } = new BitmapImage(new Uri(Constant.LoadingImgIcon)); public const int SmallIconSize = 64; @@ -223,7 +223,7 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag } catch (NotSupportedException) { - image = NoImage; + image = Image; type = ImageType.Error; } } diff --git a/Flow.Launcher/Images/image.png b/Flow.Launcher/Images/image.png index 9f26517e84ee607ab1cff7a3fdbee0b59a8d66e4..ea610046b222a9178405e41eb528e6b97f5f725a 100644 GIT binary patch literal 1122 zcmV-o1fBbdP)y5P#8DhL-&5o`nr+0EABqD#`&`NF9)8{$-_W+nQSmqfa4UmZ2?JkPwp z=aYPH+N62s`+48rOnXyf6h%=KMNt$*Q4~cPAklUVqd1OI9Iq$=NO1h_drj7iA5GvH z_u$mSk+m&$MEG>)3mBYwII6bAjtG*D9qJySrqzxJ+(VO#VJATM2#xnI8$TjBK-h)| z(gTG39)WvkaxuSK0AELt8=%dO2(kmT`9A{p(Bxu4b(Eb11(*Ac`9sJd=P1n!~9#WD4_QW9ap-UqV(l+8Uf zxj3=m5sIpA_&);o(B$H*8~pG}7Q6gfsyED5OsS|1hLSkX#o%1}=31 z@47yFr4#u1$-sV=kwzwr|M~-Z;e5^co(4#G8^F2q-MHAP0pN82=g4v6ZI=ds2JrcN zz?H8YK}~uD!Sevlr=7mugkOCC7V4WY(()8IpLU!#T<6Spbng6tjPGcqk?OH#-F$5@ku!TUvdY%=YdCg_HG+}G_r9Phr|%#zb0e}Mza?#75$0Tb zi|JeMB2v|Y@=do<`PWMg(BJsQ$667Xu?|_0*f$%Fo%|A^^89l|e!Ys)#sB=znTHbk z1h|d=!+~Z5A~9r_t{t%9wI@(=1}2d37h#o*iqPa~L&4e(=4+6+1oe(@%Pkw&r?o-?I7t%hiq zClO5M2B=EAA=;Vp2qt3#OkTxeD2WIahm-$}*+?VV3m;Nehnz_(Sqw&Z^c%tV0Y)y} zhuldk*bMa(!S?}XG(SOJc^z_#m$Mm)ZtpWf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m~T>jB*hK#Q`4sXcB72(isvO?;4It0wCKE0>bm+2t^%!SpXJ- zFq)(Xu=C_3)J#rSL^$Ir8kPq@QryEyMvwzwX%DT5pgh2dNvIWTR~W??;u{7adqKrs zX$Y=%zbt_4w$%|72YB>E5NgEgi3rW#ECAUHDw2xO=9dLPQg%71EI2w)W*Q}z;)(%~Z3qG3IcW%T0L(2s%0?0@0DKTYx|3BOz@9VH!sedR z00KgnGz3SBPZofwnO7d*kq-h$XLi&Fg{u}w^VI?%dqGYK2B=MZ ze%SkGP&#s3bpWy#@c{N-ilh8$Lh}H5o(Kxtq$8*f@X$XdASXMH2ZaWcf9dH3 zAh%mOLjFhNDg*p|0#dW{!yrmWZ=>Q`Qg;Bk^U)}0>C@t zSTBz^P6|yY*NYkjAcx!}(ku-@@#m~hpQS0pz%)At?S} zqs+Qnr!(uuurj7L4*Ncz7n*NWfSisn@@XSv9{bLA|FK)K?Z?LOOUT_T`)w;l8)Vc5OTQy=U9e?-S%+uzfdETMED;+^ItufmKEZzq4c;Z+2Z`2o#Gv zQ Date: Wed, 4 Dec 2024 10:20:21 +0800 Subject: [PATCH 12/12] Revert "Fix result update issue during modified collection enumeration" --- Flow.Launcher/ViewModel/MainViewModel.cs | 35 +++++++++--------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 7b96e0cf3c1..f964be7954d 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1447,35 +1447,26 @@ public void UpdateResultView(ICollection 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; - - Results.AddResults(resultsForUpdates, token, reSelect); - } - catch (Exception ex) - { - Log.Debug("MainViewModel", $"Error in UpdateResultView: {ex.Message}"); } - + // it should be the same for all results + bool reSelect = resultsForUpdates.First().ReSelectFirstResult; + + Results.AddResults(resultsForUpdates, token, reSelect); } #endregion