Skip to content

Commit b2c9957

Browse files
committed
Small fix
1 parent 00f2ec4 commit b2c9957

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Files.Uwp/ViewModels/SidebarViewModel.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ private async Task SyncSidebarItems(LocationItem section, IReadOnlyList<INavigat
285285
{
286286
for (int i = 0; i < e.NewItems.Count; i++)
287287
{
288-
await AddElementToSection((INavigationControlItem)e.NewItems[i], section, e.NewStartingIndex < 0 ? -1 : i + e.NewStartingIndex);
288+
var index = e.NewStartingIndex < 0 ? -1 : i + e.NewStartingIndex;
289+
await AddElementToSection((INavigationControlItem)e.NewItems[i], section, index);
289290
}
290291
break;
291292
}
@@ -295,7 +296,8 @@ private async Task SyncSidebarItems(LocationItem section, IReadOnlyList<INavigat
295296
{
296297
foreach (INavigationControlItem elem in e.OldItems)
297298
{
298-
section.ChildItems.Remove(elem);
299+
var match = section.ChildItems.FirstOrDefault(x => x.Path == elem.Path);
300+
section.ChildItems.Remove(match);
299301
}
300302
if (e.Action != NotifyCollectionChangedAction.Remove)
301303
{
@@ -309,10 +311,9 @@ private async Task SyncSidebarItems(LocationItem section, IReadOnlyList<INavigat
309311
{
310312
await AddElementToSection(elem, section);
311313
}
312-
313314
foreach (INavigationControlItem elem in section.ChildItems.ToList())
314315
{
315-
if (!elements.Contains(elem))
316+
if (!elements.Any(x => x.Path == elem.Path))
316317
{
317318
section.ChildItems.Remove(elem);
318319
}

0 commit comments

Comments
 (0)