From b5c48058cb057113e876d69e4af2f151aa87d752 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Wed, 28 Dec 2022 15:07:26 +0800 Subject: [PATCH 1/2] Fix ImageCache when loading full image No need to append ImageType to path. loadfullimage==true already indicates that it's a full image. --- Flow.Launcher.Infrastructure/Image/ImageLoader.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index deb858a79..b32ae031b 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -248,7 +248,7 @@ namespace Flow.Launcher.Infrastructure.Image public static bool CacheContainImage(string path, bool loadFullImage = false) { - return ImageCache.ContainsKey(path, false) && ImageCache[path, loadFullImage] != null; + return ImageCache.ContainsKey(path, loadFullImage) && ImageCache[path, loadFullImage] != null; } public static async ValueTask LoadAsync(string path, bool loadFullImage = false) @@ -259,10 +259,6 @@ 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) { @@ -278,7 +274,7 @@ namespace Flow.Launcher.Infrastructure.Image } // update cache - ImageCache[path, false] = img; + ImageCache[path, loadFullImage] = img; } return img; From a40e15f727f699b3e5f957b4d6698643f46caad2 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Thu, 29 Dec 2022 11:17:29 +0800 Subject: [PATCH 2/2] Remove duplicate null check null check is done in ContainsKey() --- Flow.Launcher.Infrastructure/Image/ImageCache.cs | 3 +-- Flow.Launcher.Infrastructure/Image/ImageLoader.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Image/ImageCache.cs b/Flow.Launcher.Infrastructure/Image/ImageCache.cs index 2fd2291d4..0450d91d2 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageCache.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageCache.cs @@ -1,9 +1,8 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading; -using System.Threading.Tasks; using System.Windows.Media; namespace Flow.Launcher.Infrastructure.Image diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index b32ae031b..ba8292b26 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -248,7 +248,7 @@ namespace Flow.Launcher.Infrastructure.Image public static bool CacheContainImage(string path, bool loadFullImage = false) { - return ImageCache.ContainsKey(path, loadFullImage) && ImageCache[path, loadFullImage] != null; + return ImageCache.ContainsKey(path, loadFullImage); } public static async ValueTask LoadAsync(string path, bool loadFullImage = false)