Skip to content

Commit e06e6e2

Browse files
committed
Load images into ImageCache
1 parent 3afc521 commit e06e6e2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Flow.Launcher.Infrastructure/Image/ImageLoader.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public static class ImageLoader
2424
private static readonly ConcurrentDictionary<string, string> GuidToKey = new();
2525
private static IImageHashGenerator _hashGenerator;
2626
private static readonly bool EnableImageHash = true;
27-
public static ImageSource Image { get; } = new BitmapImage(new Uri(Constant.ImageIcon));
28-
public static ImageSource MissingImage { get; } = new BitmapImage(new Uri(Constant.MissingImgIcon));
29-
public static ImageSource LoadingImage { get; } = new BitmapImage(new Uri(Constant.LoadingImgIcon));
27+
public static ImageSource Image => ImageCache[Constant.ImageIcon, false];
28+
public static ImageSource MissingImage => ImageCache[Constant.MissingImgIcon, false];
29+
public static ImageSource LoadingImage => ImageCache[Constant.LoadingImgIcon, false];
3030
public const int SmallIconSize = 64;
3131
public const int FullIconSize = 256;
3232
public const int FullImageSize = 320;
@@ -46,7 +46,7 @@ public static async Task InitializeAsync()
4646

4747
ImageCache.Initialize(usage);
4848

49-
foreach (var icon in new[] { Constant.DefaultIcon, Constant.MissingImgIcon })
49+
foreach (var icon in new[] { Constant.DefaultIcon, Constant.ImageIcon, Constant.MissingImgIcon, Constant.LoadingImgIcon })
5050
{
5151
ImageSource img = new BitmapImage(new Uri(icon));
5252
img.Freeze();
@@ -163,7 +163,7 @@ private static async ValueTask<ImageResult> LoadInternalAsync(string path, bool
163163
Log.Exception(ClassName, $"Failed to get thumbnail for {path} on first try", e);
164164
Log.Exception(ClassName, $"Failed to get thumbnail for {path} on second try", e2);
165165

166-
ImageSource image = ImageCache[Constant.MissingImgIcon, false];
166+
ImageSource image = MissingImage;
167167
ImageCache[path, false] = image;
168168
imageResult = new ImageResult(image, ImageType.Error);
169169
}
@@ -262,7 +262,7 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag
262262
}
263263
else
264264
{
265-
image = ImageCache[Constant.MissingImgIcon, false];
265+
image = MissingImage;
266266
path = Constant.MissingImgIcon;
267267
}
268268

0 commit comments

Comments
 (0)