@@ -77,10 +77,10 @@ public string HumanReadableDateModified
7777
7878 private ImageSource ? _icon ;
7979 private ImageSource ? _previewImage ;
80- private bool _isPreviewImageLoading ;
80+ private const int IconSize = 16 ;
8181 private const int PreviewIconSize = 64 ;
8282 private const int PreviewThumbnailSize = 380 ;
83- public ImageSource Icon
83+ public ImageSource ? Icon
8484 {
8585 get
8686 {
@@ -89,16 +89,19 @@ public ImageSource Icon
8989
9090 if ( ToolbarSettings . User . IsThumbnailsEnabled && IsImageFile && File . Exists ( FullPathAndFileName ) )
9191 {
92- _icon = IconProvider . GetImage ( FullPathAndFileName ) ;
92+ _icon = IconProvider . GetImage ( FullPathAndFileName , IsFile , IconSize ) ;
93+
9394 Task . Run ( ( ) =>
9495 {
95- Icon = ThumbnailProvider . GetImage ( FullPathAndFileName ) ;
96+ Icon = ThumbnailProvider . GetImage ( FullPathAndFileName , IconSize ) ;
9697 } ) ;
9798 }
9899 else
99100 {
100101 _icon = IconProvider . GetImage (
101102 FullPathAndFileName ,
103+ IsFile ,
104+ 32 ,
102105 source =>
103106 {
104107 Icon = source ;
@@ -119,34 +122,43 @@ public ImageSource? PreviewImage
119122 {
120123 get
121124 {
122- if ( _previewImage != null || _isPreviewImageLoading )
125+ if ( _previewImage != null )
123126 return _previewImage ;
124127
125- _isPreviewImageLoading = true ;
128+ var requiresThumbnail = IsImageFile && File . Exists ( FullPathAndFileName ) ;
129+
130+ // We always load the regular icon first, independent of whether the file requires a thumbnail preview
126131 Task . Run ( ( ) =>
127132 {
128- try
133+ Action < ImageSource > ? onExactIconLoaced = null ;
134+ if ( ! requiresThumbnail )
129135 {
130- ImageSource ? image = null ;
136+ onExactIconLoaced = source => { PreviewImage = source ; } ;
137+ }
131138
132- if ( IsImageFile && File . Exists ( FullPathAndFileName ) )
133- {
134- image = ThumbnailProvider . GetImage ( FullPathAndFileName , PreviewThumbnailSize ) ;
135- }
139+ ImageSource ? image = IconProvider . GetImage ( FullPathAndFileName , IsFile , PreviewIconSize , onExactIconLoaced ) ;
140+ if ( image != null && _previewImage == null )
141+ PreviewImage = image ;
142+ } ) ;
136143
137- image ??= ThumbnailProvider . GetIcon ( FullPathAndFileName , PreviewIconSize ) ;
144+ // If needed, update the preview with a thumbnail later
145+ if ( requiresThumbnail )
146+ {
147+ Task . Run ( ( ) =>
148+ {
149+ ImageSource ? image = ThumbnailProvider . GetImage (
150+ FullPathAndFileName ,
151+ PreviewThumbnailSize ,
152+ allowUpscaling : false
153+ ) ;
138154 if ( image != null )
139155 PreviewImage = image ;
140- }
141- finally
142- {
143- _isPreviewImageLoading = false ;
144- }
145- } ) ;
156+ } ) ;
157+ }
146158
147159 return _previewImage ;
148160 }
149- set
161+ private set
150162 {
151163 _previewImage = value ;
152164 OnPropertyChanged ( ) ;
0 commit comments