1
1
// Copyright (c) 2023 Files Community
2
2
// Licensed under the MIT License. See the LICENSE.
3
3
4
- using Files . App . ViewModels . Previews ;
5
4
using Files . Core . Services . SizeProvider ;
6
5
using Files . Shared . Helpers ;
7
6
using LibGit2Sharp ;
@@ -909,9 +908,9 @@ public async Task GetDefaultItemIconsAsync(uint size)
909
908
if ( currentDefaultIconSize == size )
910
909
return ;
911
910
912
- // TODO: Add more than just the folder icon
913
911
DefaultIcons . Clear ( ) ;
914
912
913
+ // TODO: Add more than just the folder icon
915
914
using StorageItemThumbnail icon = await FilesystemTasks . Wrap ( ( ) => StorageItemIconHelpers . GetIconForItemType ( size , IconPersistenceOptions . Persist ) ) ;
916
915
if ( icon is not null )
917
916
{
@@ -947,7 +946,7 @@ private async Task LoadItemThumbnailAsync(ListedItem item, uint thumbnailSize =
947
946
948
947
if ( ! iconInfo . isIconCached )
949
948
{
950
- // Display icon while trying to load cached thumbnail
949
+ // Assign a placeholder icon while trying to get a cached thumbnail
951
950
if ( iconInfo . IconData is not null )
952
951
{
953
952
await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
@@ -970,18 +969,23 @@ await dispatcherQueue.EnqueueOrInvokeAsync(async () =>
970
969
{
971
970
await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
972
971
{
972
+ // Assign the thumbnail/icon to the listed item
973
973
item . FileImage = await iconInfo . IconData . ToBitmapAsync ( ) ;
974
- if ( ! string . IsNullOrEmpty ( item . FileExtension ) &&
975
- ! item . IsShortcut && ! item . IsExecutable &&
976
- ! ImagePreviewViewModel . ContainsExtension ( item . FileExtension . ToLowerInvariant ( ) ) )
974
+
975
+ // Add the file icon to the DefaultIcons list
976
+ if ( ! DefaultIcons . ContainsKey ( item . FileExtension . ToLowerInvariant ( ) ) && ! string . IsNullOrEmpty ( item . FileExtension ) )
977
977
{
978
- DefaultIcons . AddIfNotPresent ( item . FileExtension . ToLowerInvariant ( ) , item . FileImage ) ;
978
+ var fileIcon = await FileThumbnailHelper . LoadIconAndOverlayAsync ( item . ItemPath , thumbnailSize , false , true ) ;
979
+ var bitmapImage = await fileIcon . IconData . ToBitmapAsync ( ) ;
980
+ DefaultIcons . Add ( item . FileExtension . ToLowerInvariant ( ) , bitmapImage ) ;
979
981
}
982
+
980
983
} , Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
981
984
}
982
985
983
986
if ( iconInfo . OverlayData is not null )
984
987
{
988
+ // Assign the icon overlay to the listed item
985
989
await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
986
990
{
987
991
item . IconOverlay = await iconInfo . OverlayData . ToBitmapAsync ( ) ;
@@ -993,7 +997,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(async () =>
993
997
{
994
998
var getIconOnly = UserSettingsService . FoldersSettingsService . ShowThumbnails == false || thumbnailSize < 80 ;
995
999
var iconInfo = await FileThumbnailHelper . LoadIconAndOverlayAsync ( item . ItemPath , thumbnailSize , true , getIconOnly ) ;
996
-
1000
+
997
1001
if ( iconInfo . IconData is not null )
998
1002
{
999
1003
await dispatcherQueue . EnqueueOrInvokeAsync ( async ( ) =>
0 commit comments