@@ -173,51 +173,36 @@ public ImageSource PreviewImage
173
173
174
174
public GlyphInfo Glyph { get ; set ; }
175
175
176
- private async Task LoadImageAsync ( )
176
+ private async Task < ImageSource > LoadImageInternalAsync ( string imagePath , Result . IconDelegate icon , bool loadFullImage )
177
177
{
178
- var imagePath = Result . IcoPath ;
179
- if ( string . IsNullOrEmpty ( imagePath ) && Result . Icon != null )
178
+ if ( string . IsNullOrEmpty ( imagePath ) && icon != null )
180
179
{
181
180
try
182
181
{
183
- Image = await Task . Run ( ( ) => Result . Icon ( ) ) . ConfigureAwait ( false ) ;
184
- return ;
182
+ var image = await Task . Run ( ( ) => icon ( ) ) . ConfigureAwait ( false ) ;
183
+ return image ;
185
184
}
186
185
catch ( Exception e )
187
186
{
188
187
Log . Exception (
189
- $ "|ResultViewModel.Image |IcoPath is empty and exception when calling Icon() for result <{ Result . Title } > of plugin <{ Result . PluginDirectory } >",
188
+ $ "|ResultViewModel.LoadImageInternalAsync |IcoPath is empty and exception when calling IconDelegate for result <{ Result . Title } > of plugin <{ Result . PluginDirectory } >",
190
189
e ) ;
191
190
}
192
191
}
193
192
194
- // TODO still needed after #1351?
195
- var loadFullImage = ( Path . GetExtension ( imagePath ) ?? "" ) . Equals ( ".url" , StringComparison . OrdinalIgnoreCase ) ;
196
-
197
- // TODO should use loadFullImage to hit cache?
198
- if ( ImageLoader . CacheContainImage ( imagePath ) )
199
- {
200
- // will get here either when icoPath has value\icon delegate is null\when had exception in delegate
201
- Image = await ImageLoader . LoadAsync ( imagePath , loadFullImage ) . ConfigureAwait ( false ) ;
202
- return ;
203
- }
193
+ return await ImageLoader . LoadAsync ( imagePath , loadFullImage ) . ConfigureAwait ( false ) ;
194
+ }
204
195
196
+ private async Task LoadImageAsync ( )
197
+ {
205
198
// We need to modify the property not field here to trigger the OnPropertyChanged event
206
- Image = await ImageLoader . LoadAsync ( imagePath , loadFullImage ) . ConfigureAwait ( false ) ;
199
+ Image = await LoadImageInternalAsync ( Result . IcoPath , Result . Icon , false ) . ConfigureAwait ( false ) ;
207
200
}
208
201
209
-
210
202
private async Task LoadPreviewImageAsync ( )
211
203
{
212
204
var imagePath = Result . PreviewImage ?? Result . IcoPath ;
213
- if ( imagePath == null && Result . Icon != null )
214
- {
215
- PreviewImage = await Task . Run ( ( ) => Result . Icon ( ) ) . ConfigureAwait ( false ) ;
216
- }
217
- else
218
- {
219
- PreviewImage = await ImageLoader . LoadAsync ( imagePath , true ) . ConfigureAwait ( false ) ;
220
- }
205
+ PreviewImage = await LoadImageInternalAsync ( Result . IcoPath , Result . Icon , true ) . ConfigureAwait ( false ) ;
221
206
}
222
207
223
208
public Result Result { get ; }
0 commit comments