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: Fixed icon loading delayed for quick access widget #11798

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -123,6 +124,8 @@ public QuickAccessWidget()
OpenPropertiesCommand = new RelayCommand<FolderCardItem>(OpenProperties);
PinToFavoritesCommand = new RelayCommand<FolderCardItem>(PinToFavorites);
UnpinFromFavoritesCommand = new RelayCommand<FolderCardItem>(UnpinFromFavorites);

ItemsAdded.CollectionChanged += ItemsAdded_CollectionChanged;
}

public delegate void QuickAccessCardInvokedEventHandler(object sender, QuickAccessCardInvokedEventArgs e);
Expand Down Expand Up @@ -270,8 +273,6 @@ await DispatcherQueue.EnqueueAsync(async () =>
SelectCommand = QuickAccessCardCommand
});
}
var cardLoadTasks = ItemsAdded.Select(cardItem => cardItem.LoadCardThumbnailAsync());
await Task.WhenAll(cardLoadTasks);

return;
}
Expand All @@ -287,9 +288,6 @@ await DispatcherQueue.EnqueueAsync(async () =>
SelectCommand = QuickAccessCardCommand
});
}

var cardLoadTasks = ItemsAdded.Select(cardItem => cardItem.LoadCardThumbnailAsync());
await Task.WhenAll(cardLoadTasks);
}
else
foreach (var itemToRemove in ItemsAdded.Where(x => e.Paths.Contains(x.Path)).ToList())
Expand All @@ -314,9 +312,6 @@ private async void QuickAccessWidget_Loaded(object sender, RoutedEventArgs e)
}

App.QuickAccessManager.UpdateQuickAccessWidget += ModifyItem;

var cardLoadTasks = ItemsAdded.Select(cardItem => cardItem.LoadCardThumbnailAsync());
await Task.WhenAll(cardLoadTasks);
}

private void QuickAccessWidget_Unloaded(object sender, RoutedEventArgs e)
Expand All @@ -325,6 +320,15 @@ private void QuickAccessWidget_Unloaded(object sender, RoutedEventArgs e)
App.QuickAccessManager.UpdateQuickAccessWidget -= ModifyItem;
}

private async void ItemsAdded_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action is NotifyCollectionChangedAction.Add)
{
foreach (FolderCardItem cardItem in e.NewItems!)
await cardItem.LoadCardThumbnailAsync();
}
}

private void MenuFlyout_Opening(object sender)
{
var pinToFavoritesItem = (sender as MenuFlyout)?.Items.SingleOrDefault(x => x.Name == "PinToFavorites");
Expand Down Expand Up @@ -416,8 +420,8 @@ public Task RefreshWidget()
}

public void Dispose()
{

{
ItemsAdded.CollectionChanged -= ItemsAdded_CollectionChanged;
}
}
}