@@ -21,9 +21,6 @@ public class ResultViewModel : BaseModel
2121 public ResultViewModel ( Result result , Settings settings )
2222 {
2323 Settings = settings ;
24-
25- if ( result == null ) return ;
26-
2724 Result = result ;
2825
2926 if ( Result . Glyph is { FontFamily : not null } glyph )
@@ -163,9 +160,9 @@ public ImageSource PreviewImage
163160 /// </summary>
164161 public bool UseBigThumbnail => Result . Preview . IsMedia ;
165162
166- public GlyphInfo Glyph { get ; set ; }
163+ public GlyphInfo ? Glyph { get ; set ; }
167164
168- private async Task < ImageSource > LoadImageInternalAsync ( string imagePath , Result . IconDelegate icon , bool loadFullImage )
165+ private async Task < ImageSource > LoadImageInternalAsync ( string ? imagePath , Result . IconDelegate ? icon , bool loadFullImage )
169166 {
170167 if ( string . IsNullOrEmpty ( imagePath ) && icon != null )
171168 {
@@ -181,6 +178,7 @@ private async Task<ImageSource> LoadImageInternalAsync(string imagePath, Result.
181178 }
182179 }
183180
181+ imagePath ??= string . Empty ;
184182 return await App . API . LoadImageAsync ( imagePath , loadFullImage ) . ConfigureAwait ( false ) ;
185183 }
186184
@@ -189,33 +187,29 @@ private async Task LoadImageAsync()
189187 var imagePath = Result . IcoPath ;
190188 var iconDelegate = Result . Icon ;
191189
192- if ( imagePath is null && iconDelegate is null )
193- return ;
194-
195- if ( ImageLoader . TryGetValue ( imagePath , false , out var img ) )
190+ if ( imagePath is not null && ImageLoader . TryGetValue ( imagePath , false , out var img ) )
196191 {
197192 _image = img ;
193+ return ;
198194 }
199- else
200- {
201- // We need to modify the property not field here to trigger the OnPropertyChanged event
202- Image = await LoadImageInternalAsync ( imagePath , iconDelegate , false ) . ConfigureAwait ( false ) ;
203- }
195+
196+ // We need to modify the property not field here to trigger the OnPropertyChanged event
197+ Image = await LoadImageInternalAsync ( imagePath , iconDelegate , false ) . ConfigureAwait ( false ) ;
204198 }
205199
206200 private async Task LoadPreviewImageAsync ( )
207201 {
208202 var imagePath = Result . Preview . PreviewImagePath ?? Result . IcoPath ;
209203 var iconDelegate = Result . Preview . PreviewDelegate ?? Result . Icon ;
210- if ( ImageLoader . TryGetValue ( imagePath , true , out var img ) )
204+
205+ if ( imagePath is not null && ImageLoader . TryGetValue ( imagePath , true , out var img ) )
211206 {
212207 _previewImage = img ;
208+ return ;
213209 }
214- else
215- {
216- // We need to modify the property not field here to trigger the OnPropertyChanged event
217- PreviewImage = await LoadImageInternalAsync ( imagePath , iconDelegate , true ) . ConfigureAwait ( false ) ;
218- }
210+
211+ // We need to modify the property not field here to trigger the OnPropertyChanged event
212+ PreviewImage = await LoadImageInternalAsync ( imagePath , iconDelegate , true ) . ConfigureAwait ( false ) ;
219213 }
220214
221215 public void LoadPreviewImage ( )
@@ -229,7 +223,7 @@ public void LoadPreviewImage()
229223
230224 public Result Result { get ; }
231225
232- public override bool Equals ( object obj )
226+ public override bool Equals ( object ? obj )
233227 {
234228 return obj is ResultViewModel r && Result . Equals ( r . Result ) ;
235229 }
0 commit comments