mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
change SetImage to method instead of property to avoid unintended use
This commit is contained in:
parent
2161f27a88
commit
e7c02dac72
1 changed files with 23 additions and 26 deletions
|
|
@ -19,7 +19,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
Result = result;
|
Result = result;
|
||||||
Image = new Lazy<ImageSource>(() => SetImage);
|
Image = new Lazy<ImageSource>(SetImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
|
|
@ -41,38 +41,35 @@ namespace Flow.Launcher.ViewModel
|
||||||
|
|
||||||
public Lazy<ImageSource> Image { get; set; }
|
public Lazy<ImageSource> Image { get; set; }
|
||||||
|
|
||||||
private ImageSource SetImage
|
private ImageSource SetImage()
|
||||||
{
|
{
|
||||||
get
|
var imagePath = Result.IcoPath;
|
||||||
|
if (string.IsNullOrEmpty(imagePath) && Result.Icon != null)
|
||||||
{
|
{
|
||||||
var imagePath = Result.IcoPath;
|
try
|
||||||
if (string.IsNullOrEmpty(imagePath) && Result.Icon != null)
|
|
||||||
{
|
{
|
||||||
try
|
return Result.Icon();
|
||||||
{
|
|
||||||
return Result.Icon();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.Exception($"|ResultViewModel.Image|IcoPath is empty and exception when calling Icon() for result <{Result.Title}> of plugin <{Result.PluginDirectory}>", e);
|
|
||||||
imagePath = Constant.MissingImgIcon;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
if (ImageLoader.CacheContainImage(imagePath))
|
|
||||||
// will get here either when icoPath has value\icon delegate is null\when had exception in delegate
|
|
||||||
return ImageLoader.Load(imagePath);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Task.Run(() =>
|
Log.Exception($"|ResultViewModel.Image|IcoPath is empty and exception when calling Icon() for result <{Result.Title}> of plugin <{Result.PluginDirectory}>", e);
|
||||||
{
|
imagePath = Constant.MissingImgIcon;
|
||||||
Image = new Lazy<ImageSource>(() => ImageLoader.Load(imagePath));
|
|
||||||
OnPropertyChanged(nameof(Image));
|
|
||||||
});
|
|
||||||
|
|
||||||
return ImageLoader.LoadDefault();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImageLoader.CacheContainImage(imagePath))
|
||||||
|
// will get here either when icoPath has value\icon delegate is null\when had exception in delegate
|
||||||
|
return ImageLoader.Load(imagePath);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
Image = new Lazy<ImageSource>(() => ImageLoader.Load(imagePath));
|
||||||
|
OnPropertyChanged(nameof(Image));
|
||||||
|
});
|
||||||
|
|
||||||
|
return ImageLoader.LoadDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result Result { get; }
|
public Result Result { get; }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue