Skip to content

Fix crash when favorites section is hidden #8833

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

Merged
merged 2 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion src/Files.Uwp/Controllers/SidebarPinnedController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(async () =>
});
}


public void SaveModel()
{
suppressChangeEvent = true;
Expand Down
14 changes: 8 additions & 6 deletions src/Files.Uwp/DataModels/SidebarPinnedModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,17 @@ public void RemoveStaleSidebarItems()
{
// Remove unpinned items from sidebar
// Reverse iteration to avoid skipping elements while removing
for (int i = favoriteSection.ChildItems.Count - 1; i >= 0; i--)
if (favoriteSection != null)
{
var childItem = favoriteSection.ChildItems[i];
if (childItem is LocationItem)
for (int i = favoriteSection.ChildItems.Count - 1; i >= 0; i--)
{
var item = childItem as LocationItem;
if (!item.IsDefaultLocation && !FavoriteItems.Contains(item.Path))
var childItem = favoriteSection.ChildItems[i];
if (childItem is LocationItem item)
{
favoriteSection.ChildItems.RemoveAt(i);
if (!item.IsDefaultLocation && !FavoriteItems.Contains(item.Path))
{
favoriteSection.ChildItems.RemoveAt(i);
}
}
}
}
Expand Down