Skip to content

Commit 6cedb62

Browse files
authored
Code Quality: Improved loading of pinned folders and recent files (#15259)
1 parent 516ceb2 commit 6cedb62

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/Files.App/Services/QuickAccessService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ namespace Files.App.Services
88
{
99
internal sealed class QuickAccessService : IQuickAccessService
1010
{
11-
private readonly static string guid = "::{679f85cb-0220-4080-b29b-5540cc05aab6}";
11+
// Quick access shell folder (::{679f85cb-0220-4080-b29b-5540cc05aab6}) contains recent files
12+
// which are unnecessary for getting pinned folders, so we use frequent places shell folder instead.
13+
private readonly static string guid = "::{3936e9e4-d92c-4eee-a85a-bc16d5ea0819}";
1214

1315
public async Task<IEnumerable<ShellFileItem>> GetPinnedFoldersAsync()
1416
{

src/Files.App/Utils/RecentItem/RecentItems.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ public async Task UpdateRecentFoldersAsync()
109109
/// </summary>
110110
public async Task<List<RecentItem>> ListRecentFilesAsync()
111111
{
112-
return (await Win32Helper.GetShellFolderAsync(QuickAccessGuid, false, true, 0, int.MaxValue)).Enumerate
112+
// Since the maximum number of recent files is 20, we set the count to 20 to avoid loading of unnecessary shell items.
113+
return (await Win32Helper.GetShellFolderAsync(QuickAccessGuid, false, true, 0, 20)).Enumerate
113114
.Where(link => !link.IsFolder)
114115
.Select(link => new RecentItem(link, ShowFileExtensions)).ToList();
115116
}

src/Files.App/Utils/RecentItem/RecentItemsManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public sealed class RecentItemsManager
1111
private static readonly string recentItemsPath = Environment.GetFolderPath(Environment.SpecialFolder.Recent);
1212
private static readonly string automaticDestinationsPath = Path.Combine(recentItemsPath, "AutomaticDestinations");
1313
private const string QuickAccessJumpListFileName = "5f7b5f1e01b83767.automaticDestinations-ms";
14-
private const string QuickAccessGuid = "::{679f85cb-0220-4080-b29b-5540cc05aab6}";
1514
private DateTime quickAccessLastReadTime = DateTime.MinValue;
1615
private FileSystemWatcher? quickAccessJumpListWatcher;
1716

0 commit comments

Comments
 (0)