From 5aaaf37f0cf3531b177ac76582a033f9a2c08c11 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Fri, 2 Sep 2022 08:10:52 -0400 Subject: [PATCH] Fix not loading full image --- .../Image/ImageLoader.cs | 13 ++++++------ Flow.Launcher/ViewModel/ResultViewModel.cs | 20 ------------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index 198ad5933..3c5c8b9b6 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -101,7 +101,7 @@ namespace Flow.Launcher.Infrastructure.Image } private static ImageResult LoadInternal(string path, bool loadFullImage = false) - { +{ ImageResult imageResult; try @@ -114,7 +114,7 @@ namespace Flow.Launcher.Infrastructure.Image { return new ImageResult(ImageCache[path + ImageType.FullImageFile], ImageType.Cache); } - if (ImageCache.ContainsKey(path)) + if (!loadFullImage && ImageCache.ContainsKey(path)) { return new ImageResult(ImageCache[path], ImageType.Cache); } @@ -236,10 +236,7 @@ namespace Flow.Launcher.Infrastructure.Image if (imageResult.ImageType != ImageType.Error && imageResult.ImageType != ImageType.Cache) { // we need to get image hash string hash = EnableImageHash ? _hashGenerator.GetHashFromImage(img) : null; - if (imageResult.ImageType == ImageType.FullImageFile) - { - path = path + ImageType.FullImageFile; - } + if (hash != null) { @@ -249,6 +246,10 @@ namespace Flow.Launcher.Infrastructure.Image } else { // new guid + if (imageResult.ImageType == ImageType.FullImageFile) + { + path = path + ImageType.FullImageFile; + } GuidToKey[hash] = path; } } diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs index ab02abbef..1e6ee2b92 100644 --- a/Flow.Launcher/ViewModel/ResultViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultViewModel.cs @@ -182,27 +182,7 @@ namespace Flow.Launcher.ViewModel private async ValueTask LoadPreviewImageAsync() { var imagePath = Result.PreviewImage ?? Result.IcoPath; - if (string.IsNullOrEmpty(imagePath) && Result.Icon != null) - { - try - { - previewImage = Result.Icon(); - return; - } - catch (Exception e) - { - Log.Exception( - $"|ResultViewModel.Image|IcoPath is empty and exception when calling Icon() for result <{Result.Title}> of plugin <{Result.PluginDirectory}>", - e); - } - } - if (ImageLoader.CacheContainImage(imagePath, true)) - { - // will get here either when icoPath has value\icon delegate is null\when had exception in delegate - previewImage = ImageLoader.Load(imagePath, true); - return; - } // We need to modify the property not field here to trigger the OnPropertyChanged event PreviewImage = await Task.Run(() => ImageLoader.Load(imagePath, true)).ConfigureAwait(false);