@@ -125,13 +125,21 @@ public Visibility ShowGlyph
125
125
126
126
public Visibility ShowBadge
127
127
{
128
- get => Settings . ShowBadges ? Visibility . Visible : Visibility . Collapsed ;
128
+ get
129
+ {
130
+ if ( Settings . ShowBadges && BadgeIconAvailable )
131
+ return Visibility . Visible ;
132
+
133
+ return Visibility . Collapsed ;
134
+ }
129
135
}
130
136
131
137
private bool GlyphAvailable => Glyph is not null ;
132
138
133
139
private bool ImgIconAvailable => ! string . IsNullOrEmpty ( Result . IcoPath ) || Result . Icon is not null ;
134
140
141
+ private bool BadgeIconAvailable => ! string . IsNullOrEmpty ( Result . BadgeIcoPath ) || Result . BadgeIcon is not null ;
142
+
135
143
private bool PreviewImageAvailable => ! string . IsNullOrEmpty ( Result . Preview . PreviewImagePath ) || Result . Preview . PreviewDelegate != null ;
136
144
137
145
public string OpenResultModifiers => Settings . OpenResultModifiers ;
@@ -145,9 +153,11 @@ public Visibility ShowBadge
145
153
: Result . SubTitleToolTip ;
146
154
147
155
private volatile bool _imageLoaded ;
156
+ private volatile bool _badgeImageLoaded ;
148
157
private volatile bool _previewImageLoaded ;
149
158
150
159
private ImageSource _image = ImageLoader . LoadingImage ;
160
+ private ImageSource _badgeImage = ImageLoader . LoadingImage ;
151
161
private ImageSource _previewImage = ImageLoader . LoadingImage ;
152
162
153
163
public ImageSource Image
@@ -165,6 +175,21 @@ public ImageSource Image
165
175
private set => _image = value ;
166
176
}
167
177
178
+ public ImageSource BadgeImage
179
+ {
180
+ get
181
+ {
182
+ if ( ! _badgeImageLoaded )
183
+ {
184
+ _badgeImageLoaded = true ;
185
+ _ = LoadBadgeImageAsync ( ) ;
186
+ }
187
+
188
+ return _badgeImage ;
189
+ }
190
+ private set => _badgeImage = value ;
191
+ }
192
+
168
193
public ImageSource PreviewImage
169
194
{
170
195
get
@@ -210,7 +235,7 @@ private async Task LoadImageAsync()
210
235
{
211
236
var imagePath = Result . IcoPath ;
212
237
var iconDelegate = Result . Icon ;
213
- if ( ImageLoader . TryGetValue ( imagePath , false , out ImageSource img ) )
238
+ if ( ImageLoader . TryGetValue ( imagePath , false , out var img ) )
214
239
{
215
240
_image = img ;
216
241
}
@@ -221,11 +246,26 @@ private async Task LoadImageAsync()
221
246
}
222
247
}
223
248
249
+ private async Task LoadBadgeImageAsync ( )
250
+ {
251
+ var badgeImagePath = Result . BadgeIcoPath ;
252
+ var badgeIconDelegate = Result . BadgeIcon ;
253
+ if ( ImageLoader . TryGetValue ( badgeImagePath , false , out var img ) )
254
+ {
255
+ _badgeImage = img ;
256
+ }
257
+ else
258
+ {
259
+ // We need to modify the property not field here to trigger the OnPropertyChanged event
260
+ BadgeImage = await LoadImageInternalAsync ( badgeImagePath , badgeIconDelegate , false ) . ConfigureAwait ( false ) ;
261
+ }
262
+ }
263
+
224
264
private async Task LoadPreviewImageAsync ( )
225
265
{
226
266
var imagePath = Result . Preview . PreviewImagePath ?? Result . IcoPath ;
227
267
var iconDelegate = Result . Preview . PreviewDelegate ?? Result . Icon ;
228
- if ( ImageLoader . TryGetValue ( imagePath , true , out ImageSource img ) )
268
+ if ( ImageLoader . TryGetValue ( imagePath , true , out var img ) )
229
269
{
230
270
_previewImage = img ;
231
271
}
0 commit comments