Skip to content

Commit 1c9f79d

Browse files
authored
Fix recent files not showing (#5997)
1 parent d2fd9a2 commit 1c9f79d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Files/UserControls/Widgets/RecentFilesWidget.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private async Task AddItemToRecentListAsync(IStorageItem item, AccessListEntry e
126126
// This is only needed to remove files opened from a disconnected android/MTP phone
127127
if (string.IsNullOrEmpty(item.Path)) // This indicates that the file was open from an MTP device
128128
{
129-
using (var inputStream = await ((BaseStorageFile)item).OpenReadAsync())
129+
using (var inputStream = await item.AsBaseStorageFile().OpenReadAsync())
130130
using (var classicStream = inputStream.AsStreamForRead())
131131
using (var streamReader = new StreamReader(classicStream))
132132
{
@@ -139,7 +139,7 @@ private async Task AddItemToRecentListAsync(IStorageItem item, AccessListEntry e
139139
ItemPath = string.IsNullOrEmpty(item.Path) ? entry.Metadata : item.Path;
140140
ItemType = StorageItemTypes.File;
141141
ItemImage = new BitmapImage();
142-
BaseStorageFile file = (BaseStorageFile)item;
142+
BaseStorageFile file = item.AsBaseStorageFile();
143143
using var thumbnail = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.ListView, 24, Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale);
144144
if (thumbnail == null)
145145
{

Files/ViewModels/ItemViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(async () =>
766766
{
767767
if (!item.IsShortcutItem && !item.IsHiddenItem && !FtpHelpers.IsFtpPath(item.ItemPath))
768768
{
769-
var matchingStorageFile = (BaseStorageFile)matchingStorageItem ?? await GetFileFromPathAsync(item.ItemPath);
769+
var matchingStorageFile = matchingStorageItem.AsBaseStorageFile() ?? await GetFileFromPathAsync(item.ItemPath);
770770
if (matchingStorageFile != null)
771771
{
772772
var mode = thumbnailSize < 80 ? ThumbnailMode.ListView : ThumbnailMode.SingleItem;
@@ -839,7 +839,7 @@ await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(async () =>
839839
{
840840
if (!item.IsShortcutItem && !item.IsHiddenItem && !FtpHelpers.IsFtpPath(item.ItemPath))
841841
{
842-
var matchingStorageFolder = (BaseStorageFolder)matchingStorageItem ?? await GetFolderFromPathAsync(item.ItemPath);
842+
var matchingStorageFolder = matchingStorageItem.AsBaseStorageFolder() ?? await GetFolderFromPathAsync(item.ItemPath);
843843
if (matchingStorageFolder != null)
844844
{
845845
var mode = thumbnailSize < 80 ? ThumbnailMode.ListView : ThumbnailMode.SingleItem;

0 commit comments

Comments
 (0)