@@ -173,51 +173,36 @@ public ImageSource PreviewImage
173173
174174 public GlyphInfo Glyph { get ; set ; }
175175
176- private async Task LoadImageAsync ( )
176+ private async Task < ImageSource > LoadImageInternalAsync ( string imagePath , Result . IconDelegate icon , bool loadFullImage )
177177 {
178- var imagePath = Result . IcoPath ;
179- if ( string . IsNullOrEmpty ( imagePath ) && Result . Icon != null )
178+ if ( string . IsNullOrEmpty ( imagePath ) && icon != null )
180179 {
181180 try
182181 {
183- Image = await Task . Run ( ( ) => Result . Icon ( ) ) . ConfigureAwait ( false ) ;
184- return ;
182+ var image = await Task . Run ( ( ) => icon ( ) ) . ConfigureAwait ( false ) ;
183+ return image ;
185184 }
186185 catch ( Exception e )
187186 {
188187 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 } >",
190189 e ) ;
191190 }
192191 }
193192
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+ }
204195
196+ private async Task LoadImageAsync ( )
197+ {
205198 // 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 ) ;
207200 }
208201
209-
210202 private async Task LoadPreviewImageAsync ( )
211203 {
212204 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 ) ;
221206 }
222207
223208 public Result Result { get ; }
0 commit comments