diff --git a/src/Files.App/UserControls/SearchBox.xaml b/src/Files.App/UserControls/SearchBox.xaml index 034c48b15b3d..aa9eef41149f 100644 --- a/src/Files.App/UserControls/SearchBox.xaml +++ b/src/Files.App/UserControls/SearchBox.xaml @@ -48,8 +48,8 @@ Spacing="8" Tag="{x:Bind ItemPath}"> @@ -98,6 +99,12 @@ + + + + diff --git a/src/Files.App/Utils/Storage/Search/FolderSearch.cs b/src/Files.App/Utils/Storage/Search/FolderSearch.cs index 79762fa16f29..08df6e230def 100644 --- a/src/Files.App/Utils/Storage/Search/FolderSearch.cs +++ b/src/Files.App/Utils/Storage/Search/FolderSearch.cs @@ -21,10 +21,10 @@ public sealed class FolderSearch private const uint defaultStepSize = 500; public string? Query { get; set; } + public string? Folder { get; set; } public uint MaxItemCount { get; set; } = 0; // 0: no limit - public uint ThumbnailSize { get; set; } = 24; private uint UsedMaxItemCount => MaxItemCount > 0 ? MaxItemCount : uint.MaxValue; @@ -392,20 +392,28 @@ private ListedItem GetListedItemAsync(string itemPath, WIN32_FIND_DATA findData) }; } } + if (listedItem is not null && MaxItemCount > 0) // Only load icon for searchbox suggestions { - _ = FileThumbnailHelper.LoadIconFromPathAsync(listedItem.ItemPath, ThumbnailSize, ThumbnailMode.ListView, ThumbnailOptions.ResizeThumbnail, isFolder) + _ = FileThumbnailHelper.GetIconAsync( + listedItem.ItemPath, + Constants.ShellIconSizes.Small, + isFolder, + IconOptions.ReturnIconOnly | IconOptions.UseCurrentScale) .ContinueWith((t) => { if (t.IsCompletedSuccessfully && t.Result is not null) { _ = FilesystemTasks.Wrap(() => MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () => { - listedItem.FileImage = await t.Result.ToBitmapAsync(); + var bitmapImage = await t.Result.ToBitmapAsync(); + if (bitmapImage is not null) + listedItem.FileImage = bitmapImage; }, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low)); } }); } + return listedItem; } diff --git a/src/Files.App/Views/Layouts/BaseLayoutPage.cs b/src/Files.App/Views/Layouts/BaseLayoutPage.cs index 8013e40ffcbb..c38181d24653 100644 --- a/src/Files.App/Views/Layouts/BaseLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseLayoutPage.cs @@ -482,7 +482,6 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) { Query = navigationArguments.SearchQuery, Folder = navigationArguments.SearchPathParam, - ThumbnailSize = InstanceViewModel!.FolderSettings.GetRoundedIconSize(), }; _ = ParentShellPageInstance.ShellViewModel.SearchAsync(searchInstance); diff --git a/src/Files.App/Views/Shells/BaseShellPage.cs b/src/Files.App/Views/Shells/BaseShellPage.cs index 305c8d211aa4..e7dbc45c0882 100644 --- a/src/Files.App/Views/Shells/BaseShellPage.cs +++ b/src/Files.App/Views/Shells/BaseShellPage.cs @@ -553,7 +553,6 @@ public async Task Refresh_Click() { Query = InstanceViewModel.CurrentSearchQuery ?? (string)TabBarItemParameter.NavigationParameter, Folder = ShellViewModel.WorkingDirectory, - ThumbnailSize = InstanceViewModel.FolderSettings.GetRoundedIconSize(), }; await ShellViewModel.SearchAsync(searchInstance);