Skip to content

Commit 58b2940

Browse files
authored
Icon/Filesystem Fixes (#812)
* Revert exclusive use of cached thumbnails to previous method * Cancel long-running item query when Back is invoked
1 parent c84eb42 commit 58b2940

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Files/View Models/ItemViewModel.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Threading;
1919
using System.Threading.Tasks;
2020
using Windows.ApplicationModel.Core;
21+
using Windows.Foundation;
2122
using Windows.Storage;
2223
using Windows.Storage.FileProperties;
2324
using Windows.Storage.Search;
@@ -397,7 +398,7 @@ public void CancelLoadAndClearFiles()
397398
{
398399
_itemQueryResult.ContentsChanged -= FileContentsChanged;
399400
}
400-
401+
watchedItemsOperation.Cancel();
401402
App.CurrentInstance.NavigationToolbar.CanGoBack = true;
402403
App.CurrentInstance.NavigationToolbar.CanGoForward = true;
403404
App.CurrentInstance.NavigationToolbar.CanNavigateToParent = true;
@@ -609,7 +610,7 @@ public async void LoadExtendedItemProperties(ListedItem item, uint thumbnailSize
609610
{
610611
matchingItem.FolderRelativeId = matchingStorageItem.FolderRelativeId;
611612
matchingItem.ItemType = matchingStorageItem.DisplayType;
612-
using (var Thumbnail = await matchingStorageItem.GetThumbnailAsync(ThumbnailMode.SingleItem, thumbnailSize, ThumbnailOptions.ReturnOnlyIfCached))
613+
using (var Thumbnail = await matchingStorageItem.GetThumbnailAsync(ThumbnailMode.SingleItem, thumbnailSize, ThumbnailOptions.UseCurrentScale))
613614
{
614615
if (Thumbnail != null)
615616
{
@@ -655,6 +656,8 @@ public async Task RefreshItems()
655656
await AddItemsToCollectionAsync(WorkingDirectory);
656657
}
657658
public IReadOnlyList<IStorageItem> watchedItems = null;
659+
private IAsyncOperation<IReadOnlyList<IStorageItem>> watchedItemsOperation;
660+
658661
public async Task RapidAddItemsToCollectionAsync(string path)
659662
{
660663
App.CurrentInstance.NavigationToolbar.CanRefresh = false;
@@ -724,7 +727,7 @@ public async Task RapidAddItemsToCollectionAsync(string path)
724727
FileSizeBytes = 0
725728
};
726729

727-
await Task.Run(async () =>
730+
await Task.Run(() =>
728731
{
729732
var options = new QueryOptions()
730733
{
@@ -735,10 +738,9 @@ await Task.Run(async () =>
735738
options.SetThumbnailPrefetch(ThumbnailMode.ListView, 0, ThumbnailOptions.ReturnOnlyIfCached);
736739
_itemQueryResult = _rootFolder.CreateItemQueryWithOptions(options);
737740
_itemQueryResult.ContentsChanged += FileContentsChanged;
738-
watchedItems = await _itemQueryResult.GetItemsAsync();
739-
741+
watchedItemsOperation = _itemQueryResult.GetItemsAsync();
742+
watchedItemsOperation.Completed += delegate { watchedItems = watchedItemsOperation.GetResults(); };
740743
});
741-
742744
}
743745
catch (UnauthorizedAccessException)
744746
{

0 commit comments

Comments
 (0)