Skip to content

Commit dda6d97

Browse files
committed
Fix up 1
1 parent 31050e2 commit dda6d97

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/Files.App/Services/Windows/WindowsQuickAccessService.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public async Task InitializeAsync()
5454

5555
public async Task<bool> UpdatePinnedFoldersAsync()
5656
{
57-
return await Task.Run(() =>
57+
return await Task.Run(async () =>
5858
{
5959
try
6060
{
61-
List<LocationItem> items = [];
61+
List<INavigationControlItem> items = [];
6262
foreach (var path in GetPinnedFolders())
6363
items.Add(await CreateItemOf(path));
6464

@@ -75,13 +75,16 @@ public async Task<bool> UpdatePinnedFoldersAsync()
7575

7676
var eventArgs = GetChangedActionEventArgs(snapshot, items);
7777
PinnedFoldersChanged?.Invoke(this, eventArgs);
78+
79+
return true;
7880
}
7981
catch
8082
{
83+
return false;
8184
}
8285
});
8386

84-
unsafe IEnumerable<string> GetPinnedFolders()
87+
unsafe List<string> GetPinnedFolders()
8588
{
8689
HRESULT hr = default;
8790

@@ -99,6 +102,7 @@ unsafe IEnumerable<string> GetPinnedFolders()
99102

100103
// Enumerate pinned folders
101104
int index = 0;
105+
List<string> paths = [];
102106
using ComPtr<IShellItem> pShellItem = default;
103107
while (pEnumShellItems.Get()->Next(1, pShellItem.GetAddressOf()) == HRESULT.S_OK)
104108
{
@@ -114,10 +118,12 @@ unsafe IEnumerable<string> GetPinnedFolders()
114118
var path = szDisplayName.ToString();
115119
PInvoke.CoTaskMemFree(szDisplayName.Value);
116120

117-
yield return path;
121+
paths.Add(path);
118122

119123
index++;
120124
}
125+
126+
return paths;
121127
}
122128

123129
async Task<LocationItem> CreateItemOf(string path)
@@ -181,7 +187,7 @@ async Task<LocationItem> CreateItemOf(string path)
181187
return locationItem;
182188
}
183189

184-
NotifyCollectionChangedEventArgs GetChangedActionEventArgs(IReadOnlyList<LocationItem> oldItems, IList<LocationItem> newItems)
190+
NotifyCollectionChangedEventArgs GetChangedActionEventArgs(IReadOnlyList<INavigationControlItem> oldItems, IList<INavigationControlItem> newItems)
185191
{
186192
if (newItems.Count - oldItems.Count is 1)
187193
{

src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ private async Task UpdateCollectionAsync(NotifyCollectionChangedEventArgs e)
145145
{
146146
if (e.NewItems is not null)
147147
{
148-
// e.NewItems.Cast<LocationItem>().Single()
149-
var cardItem = new WidgetFolderCardItem();
148+
var item = e.NewItems.Cast<LocationItem>().Single();
149+
var cardItem = new WidgetFolderCardItem(item, SystemIO.Path.GetFileName(item.Text), true) { Path = item.Path };
150150
AddItemToCollection(cardItem);
151151
}
152152
}
@@ -157,8 +157,8 @@ private async Task UpdateCollectionAsync(NotifyCollectionChangedEventArgs e)
157157
{
158158
Items.RemoveAt(e.OldStartingIndex);
159159

160-
// e.NewItems.Cast<LocationItem>().Single()
161-
var cardItem = new WidgetFolderCardItem();
160+
var item = e.NewItems.Cast<LocationItem>().Single();
161+
var cardItem = new WidgetFolderCardItem(item, SystemIO.Path.GetFileName(item.Text), true) { Path = item.Path };
162162
AddItemToCollection(cardItem);
163163
}
164164
}
@@ -178,7 +178,7 @@ private async Task UpdateCollectionAsync(NotifyCollectionChangedEventArgs e)
178178
Items.Clear();
179179
foreach (var item in items)
180180
{
181-
var cardItem = new WidgetFolderCardItem();
181+
var cardItem = new WidgetFolderCardItem(item, SystemIO.Path.GetFileName(item.Text), true) { Path = item.Path };
182182
AddItemToCollection(cardItem);
183183
}
184184
}

0 commit comments

Comments
 (0)