Skip to content

Commit e9f317f

Browse files
committed
Change variable names
1 parent 655b017 commit e9f317f

File tree

1 file changed

+28
-37
lines changed

1 file changed

+28
-37
lines changed

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace Flow.Launcher.ViewModel
1414
{
1515
public class ResultViewModel : BaseModel
1616
{
17-
private static readonly PrivateFontCollection fontCollection = new();
18-
private static readonly Dictionary<string, string> fonts = new();
17+
private static readonly PrivateFontCollection FontCollection = new();
18+
private static readonly Dictionary<string, string> Fonts = new();
1919

2020
public ResultViewModel(Result result, Settings settings)
2121
{
@@ -37,7 +37,7 @@ public ResultViewModel(Result result, Settings settings)
3737
fontFamilyPath = Path.Combine(Result.PluginDirectory, fontFamilyPath);
3838
}
3939

40-
if (fonts.TryGetValue(fontFamilyPath, out var value))
40+
if (Fonts.TryGetValue(fontFamilyPath, out var value))
4141
{
4242
Glyph = glyph with
4343
{
@@ -46,11 +46,11 @@ public ResultViewModel(Result result, Settings settings)
4646
}
4747
else
4848
{
49-
fontCollection.AddFontFile(fontFamilyPath);
50-
fonts[fontFamilyPath] = $"{Path.GetDirectoryName(fontFamilyPath)}/#{fontCollection.Families[^1].Name}";
49+
FontCollection.AddFontFile(fontFamilyPath);
50+
Fonts[fontFamilyPath] = $"{Path.GetDirectoryName(fontFamilyPath)}/#{FontCollection.Families[^1].Name}";
5151
Glyph = glyph with
5252
{
53-
FontFamily = fonts[fontFamilyPath]
53+
FontFamily = Fonts[fontFamilyPath]
5454
};
5555
}
5656
}
@@ -92,14 +92,10 @@ public Visibility ShowPreviewImage
9292
get
9393
{
9494
if (PreviewImageAvailable)
95-
{
9695
return Visibility.Visible;
97-
}
98-
else
99-
{
100-
// Fall back to icon
101-
return ShowIcon;
102-
}
96+
97+
// Fall back to icon
98+
return ShowIcon;
10399
}
104100
}
105101

@@ -108,9 +104,8 @@ public double IconRadius
108104
get
109105
{
110106
if (Result.RoundedIcon)
111-
{
112107
return IconXY / 2;
113-
}
108+
114109
return IconXY;
115110
}
116111

@@ -145,40 +140,40 @@ public Visibility ShowGlyph
145140
? Result.SubTitle
146141
: Result.SubTitleToolTip;
147142

148-
private volatile bool ImageLoaded;
149-
private volatile bool PreviewImageLoaded;
143+
private volatile bool _imageLoaded;
144+
private volatile bool _previewImageLoaded;
150145

151-
private ImageSource image = ImageLoader.LoadingImage;
152-
private ImageSource previewImage = ImageLoader.LoadingImage;
146+
private ImageSource _image = ImageLoader.LoadingImage;
147+
private ImageSource _previewImage = ImageLoader.LoadingImage;
153148

154149
public ImageSource Image
155150
{
156151
get
157152
{
158-
if (!ImageLoaded)
153+
if (!_imageLoaded)
159154
{
160-
ImageLoaded = true;
155+
_imageLoaded = true;
161156
_ = LoadImageAsync();
162157
}
163158

164-
return image;
159+
return _image;
165160
}
166-
private set => image = value;
161+
private set => _image = value;
167162
}
168163

169164
public ImageSource PreviewImage
170165
{
171166
get
172167
{
173-
if (!PreviewImageLoaded)
168+
if (!_previewImageLoaded)
174169
{
175-
PreviewImageLoaded = true;
170+
_previewImageLoaded = true;
176171
_ = LoadPreviewImageAsync();
177172
}
178173

179-
return previewImage;
174+
return _previewImage;
180175
}
181-
private set => previewImage = value;
176+
private set => _previewImage = value;
182177
}
183178

184179
/// <summary>
@@ -194,8 +189,7 @@ private async Task<ImageSource> LoadImageInternalAsync(string imagePath, Result.
194189
{
195190
try
196191
{
197-
var image = icon();
198-
return image;
192+
return icon();
199193
}
200194
catch (Exception e)
201195
{
@@ -214,7 +208,7 @@ private async Task LoadImageAsync()
214208
var iconDelegate = Result.Icon;
215209
if (ImageLoader.TryGetValue(imagePath, false, out ImageSource img))
216210
{
217-
image = img;
211+
_image = img;
218212
}
219213
else
220214
{
@@ -229,7 +223,7 @@ private async Task LoadPreviewImageAsync()
229223
var iconDelegate = Result.Preview.PreviewDelegate ?? Result.Icon;
230224
if (ImageLoader.TryGetValue(imagePath, true, out ImageSource img))
231225
{
232-
previewImage = img;
226+
_previewImage = img;
233227
}
234228
else
235229
{
@@ -240,13 +234,10 @@ private async Task LoadPreviewImageAsync()
240234

241235
public void LoadPreviewImage()
242236
{
243-
if (ShowDefaultPreview == Visibility.Visible)
237+
if (ShowDefaultPreview == Visibility.Visible && !_previewImageLoaded && ShowPreviewImage == Visibility.Visible)
244238
{
245-
if (!PreviewImageLoaded && ShowPreviewImage == Visibility.Visible)
246-
{
247-
PreviewImageLoaded = true;
248-
_ = LoadPreviewImageAsync();
249-
}
239+
_previewImageLoaded = true;
240+
_ = LoadPreviewImageAsync();
250241
}
251242
}
252243

0 commit comments

Comments
 (0)