Fix not loading full image

This commit is contained in:
Garulf 2022-09-02 08:10:52 -04:00
parent 9ed008fef6
commit 5aaaf37f0c
2 changed files with 7 additions and 26 deletions

View file

@ -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;
}
}

View file

@ -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);