Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Another fix for thumbnails #14936

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/Files.App/Data/Models/ItemViewModel.cs
Expand Up @@ -916,7 +916,6 @@ private async Task<BitmapImage> GetShieldIcon()

private async Task LoadThumbnailAsync(ListedItem item)
{
// Cancel if thumbnails aren't enabled
var thumbnailSize = folderSettings.GetRoundedIconSize();
var returnIconOnly = UserSettingsService.FoldersSettingsService.ShowThumbnails == false || thumbnailSize < 48;

Expand Down Expand Up @@ -989,8 +988,6 @@ public async Task LoadExtendedItemPropertiesAsync(ListedItem item)
loadGroupHeaderInfo = gp is not null && !gp.Model.Initialized && gp.GetExtendedGroupHeaderInfo is not null;
}

cts.Token.ThrowIfCancellationRequested();
await LoadThumbnailAsync(item);

cts.Token.ThrowIfCancellationRequested();
if (item.IsLibrary || item.PrimaryItemAttribute == StorageItemTypes.File || item.IsArchive)
Expand All @@ -1000,6 +997,9 @@ public async Task LoadExtendedItemPropertiesAsync(ListedItem item)
matchingStorageFile = await GetFileFromPathAsync(item.ItemPath, cts.Token);
if (matchingStorageFile is not null)
{
cts.Token.ThrowIfCancellationRequested();
await LoadThumbnailAsync(item);

cts.Token.ThrowIfCancellationRequested();

var syncStatus = await CheckCloudDriveSyncStatusAsync(matchingStorageFile);
Expand Down Expand Up @@ -1032,6 +1032,11 @@ public async Task LoadExtendedItemPropertiesAsync(ListedItem item)
BaseStorageFolder matchingStorageFolder = await GetFolderFromPathAsync(item.ItemPath, cts.Token);
if (matchingStorageFolder is not null)
{
cts.Token.ThrowIfCancellationRequested();
await LoadThumbnailAsync(item);
Copy link
Member Author

@yaira2 yaira2 Mar 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is resolved when we request the thumbnail after executing GetFolderFromPathAsync. However, this causes a new issue where excessive scrolling crashes the app.


cts.Token.ThrowIfCancellationRequested();
Comment on lines +1036 to +1038
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await LoadThumbnailAsync(item);
cts.Token.ThrowIfCancellationRequested();
_ = LoadThumbnailAsync(item);

This seems to avoid crashes, but is that still going to solve the issue?


if (matchingStorageFolder.DisplayName != item.Name && !matchingStorageFolder.DisplayName.StartsWith("$R", StringComparison.Ordinal))
{
cts.Token.ThrowIfCancellationRequested();
Expand Down Expand Up @@ -1097,16 +1102,15 @@ public async Task LoadExtendedItemPropertiesAsync(ListedItem item)
SetFileTag(item);
});
}
else
else if (UserSettingsService.FoldersSettingsService.ShowThumbnails && item.SyncStatusUI.SyncStatus != CloudDriveSyncStatus.NotSynced && item.SyncStatusUI.SyncStatus != CloudDriveSyncStatus.Unknown)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else if (UserSettingsService.FoldersSettingsService.ShowThumbnails && item.SyncStatusUI.SyncStatus != CloudDriveSyncStatus.NotSynced && item.SyncStatusUI.SyncStatus != CloudDriveSyncStatus.Unknown)
else if (item.SyncStatusUI.SyncStatus != CloudDriveSyncStatus.NotSynced && item.SyncStatusUI.SyncStatus != CloudDriveSyncStatus.Unknown)

{
// Try loading thumbnail for cloud files in case they weren't cached the first time
if (item.SyncStatusUI.SyncStatus != CloudDriveSyncStatus.NotSynced && item.SyncStatusUI.SyncStatus != CloudDriveSyncStatus.Unknown)
// Load thumbnail for folders (we initially load a basic folder icon to prevent a bug where thumbnails stop loading #14817)
// Also reload thumbnails cloud files in case they weren't cached the first time
_ = Task.Run(async () =>
{
_ = Task.Run(async () => {
await Task.Delay(500);
await LoadThumbnailAsync(item);
});
}
await Task.Delay(500);
await LoadThumbnailAsync(item);
});
}

if (loadGroupHeaderInfo)
Expand Down