Skip to content

Commit 9e178c0

Browse files
authored
Code Quality: Transition Sidebar and Tabs away from LoadIconFromPathAsync (#14701)
1 parent 5b9f84c commit 9e178c0

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

src/Files.App/Data/Models/SidebarPinnedModel.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,12 @@ public async Task<LocationItem> CreateLocationItemFromPathAsync(string path)
102102
locationItem.IsInvalid = false;
103103
if (res && res.Result is not null)
104104
{
105-
var iconData = await FileThumbnailHelper.LoadIconFromStorageItemAsync(res.Result, 16u, ThumbnailMode.ListView, ThumbnailOptions.UseCurrentScale);
105+
var iconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(res.Result.Path, 28u, true, false, true);
106106
locationItem.IconData = iconData;
107107

108108
if (locationItem.IconData is not null)
109109
locationItem.Icon = await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => locationItem.IconData.ToBitmapAsync());
110110
}
111-
112-
if (locationItem.IconData is null)
113-
{
114-
locationItem.IconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(path, 48u, false, false, true);
115-
116-
if (locationItem.IconData is not null)
117-
locationItem.Icon = await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => locationItem.IconData.ToBitmapAsync());
118-
}
119111
}
120112
else
121113
{

src/Files.App/Helpers/Navigation/NavigationHelpers.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,30 +137,15 @@ private static async Task UpdateTabInfoAsync(TabBarItem tabItem, object navigati
137137
iconSource.ImageSource = new BitmapImage(new Uri(Constants.FluentIconsPaths.HomeIcon));
138138
}
139139
else if (currentPath.Equals(Constants.UserEnvironmentPaths.DesktopPath, StringComparison.OrdinalIgnoreCase))
140-
{
141140
tabLocationHeader = "Desktop".GetLocalizedResource();
142-
}
143141
else if (currentPath.Equals(Constants.UserEnvironmentPaths.DownloadsPath, StringComparison.OrdinalIgnoreCase))
144-
{
145142
tabLocationHeader = "Downloads".GetLocalizedResource();
146-
}
147143
else if (currentPath.Equals(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
148-
{
149144
tabLocationHeader = "RecycleBin".GetLocalizedResource();
150-
151-
// Use 48 for higher resolution, the other items look fine with 16.
152-
var iconData = await FileThumbnailHelper.LoadIconFromPathAsync(currentPath, 48u, Windows.Storage.FileProperties.ThumbnailMode.ListView, Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale, true);
153-
if (iconData is not null)
154-
iconSource.ImageSource = await iconData.ToBitmapAsync();
155-
}
156145
else if (currentPath.Equals(Constants.UserEnvironmentPaths.MyComputerPath, StringComparison.OrdinalIgnoreCase))
157-
{
158146
tabLocationHeader = "ThisPC".GetLocalizedResource();
159-
}
160147
else if (currentPath.Equals(Constants.UserEnvironmentPaths.NetworkFolderPath, StringComparison.OrdinalIgnoreCase))
161-
{
162148
tabLocationHeader = "SidebarNetworkDrives".GetLocalizedResource();
163-
}
164149
else if (App.LibraryManager.TryGetLibrary(currentPath, out LibraryLocationItem library))
165150
{
166151
var libName = System.IO.Path.GetFileNameWithoutExtension(library.Path).GetLocalizedResource();
@@ -203,7 +188,7 @@ private static async Task UpdateTabInfoAsync(TabBarItem tabItem, object navigati
203188

204189
if (iconSource.ImageSource is null)
205190
{
206-
var iconData = await FileThumbnailHelper.LoadIconFromPathAsync(currentPath, 16u, Windows.Storage.FileProperties.ThumbnailMode.ListView, Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale, true);
191+
var iconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(currentPath, 28u, true, false, true);
207192
if (iconData is not null)
208193
iconSource.ImageSource = await iconData.ToBitmapAsync();
209194
}

0 commit comments

Comments
 (0)