Skip to content

Commit 5a077f9

Browse files
Fix preview image size when PreviewImage is null
1 parent 1e8fe93 commit 5a077f9

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ public ResultViewModel(Result result, Settings settings)
2828
}
2929
Result = result;
3030

31-
PreviewExtension = Path.GetExtension(result.PreviewImage ?? result.SubTitle);
32-
if (PreviewExtension != null)
31+
var extension = Path.GetExtension(result.PreviewImage);
32+
if (!string.IsNullOrEmpty(extension))
3333
{
34-
PreviewExtension = PreviewExtension.ToLowerInvariant();
34+
// only when explicitly specified PreviewImage
35+
PreviewIsImageOrVideo = IsMedia(extension.ToLowerInvariant());
3536
}
3637

3738
if (Result.Glyph is { FontFamily: not null } glyph)
@@ -173,18 +174,21 @@ public ImageSource PreviewImage
173174
private set => previewImage = value;
174175
}
175176

176-
public string PreviewExtension { get; set; }
177-
178-
public bool PreviewIsImageOrVideo => PreviewExtension is ".jpg"
179-
or ".png"
180-
or ".avi"
181-
or ".mkv"
182-
or ".bmp"
183-
or ".gif"
184-
or ".wmv"
185-
or ".mp3"
186-
or ".flac"
187-
or ".mp4";
177+
public bool PreviewIsImageOrVideo { get; set; } = false;
178+
179+
public bool IsMedia(string extension)
180+
{
181+
return extension is ".jpg"
182+
or ".png"
183+
or ".avi"
184+
or ".mkv"
185+
or ".bmp"
186+
or ".gif"
187+
or ".wmv"
188+
or ".mp3"
189+
or ".flac"
190+
or ".mp4";
191+
}
188192

189193
public GlyphInfo Glyph { get; set; }
190194

0 commit comments

Comments
 (0)