Skip to content

Commit

Permalink
Code Quality: Improved loading speed of thumbnails - part 2 (#14618)
Browse files Browse the repository at this point in the history
  • Loading branch information
hishitetsu authored Feb 1, 2024
1 parent 6718879 commit 92126e3
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/Files.App/Data/Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,9 @@ await Task.Run(async () =>
loadGroupHeaderInfo = gp is not null && !gp.Model.Initialized && gp.GetExtendedGroupHeaderInfo is not null;
}

cts.Token.ThrowIfCancellationRequested();
await LoadItemThumbnailAsync(item, thumbnailSize);

if (item.IsLibrary || item.PrimaryItemAttribute == StorageItemTypes.File || item.IsArchive)
{
if (!item.IsShortcut && !item.IsHiddenItem && !FtpHelpers.IsFtpPath(item.ItemPath))
Expand Down Expand Up @@ -1093,13 +1096,8 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>

SetFileTag(item);
wasSyncStatusLoaded = true;

await LoadItemThumbnailAsync(item, thumbnailSize);
}
}

if (!wasSyncStatusLoaded)
await LoadItemThumbnailAsync(item, thumbnailSize);
}
else
{
Expand All @@ -1109,8 +1107,6 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
BaseStorageFolder matchingStorageFolder = await GetFolderFromPathAsync(item.ItemPath, cts.Token);
if (matchingStorageFolder is not null)
{
cts.Token.ThrowIfCancellationRequested();
await LoadItemThumbnailAsync(item, thumbnailSize);
if (matchingStorageFolder.DisplayName != item.Name && !matchingStorageFolder.DisplayName.StartsWith("$R", StringComparison.Ordinal))
{
cts.Token.ThrowIfCancellationRequested();
Expand Down Expand Up @@ -1147,11 +1143,6 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
wasSyncStatusLoaded = true;
}
}
if (!wasSyncStatusLoaded)
{
cts.Token.ThrowIfCancellationRequested();
await LoadItemThumbnailAsync(item, thumbnailSize);
}
}

if (loadGroupHeaderInfo && isFileTypeGroupMode)
Expand Down

0 comments on commit 92126e3

Please sign in to comment.