Skip to content

Commit 2e55513

Browse files
authored
Fixed an issue where duplicate WSL sections appeared on sidebar (#4193)
1 parent b866e7f commit 2e55513

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

Files/Filesystem/WSLDistroManager.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,18 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
5151
if ((await distroFolder.GetFoldersAsync()).Count != 0)
5252
{
5353
var section = MainPage.SideBarItems.FirstOrDefault(x => x.Text == "WSL") as LocationItem;
54-
55-
section = new LocationItem()
54+
if (section == null)
5655
{
57-
Text = "WSL",
58-
Section = SectionType.WSL,
59-
Glyph = "\uEC7A",
60-
SelectsOnInvoked = false,
61-
ChildItems = new ObservableCollection<INavigationControlItem>()
62-
};
63-
MainPage.SideBarItems.Add(section);
56+
section = new LocationItem()
57+
{
58+
Text = "WSL",
59+
Section = SectionType.WSL,
60+
Glyph = "\uEC7A",
61+
SelectsOnInvoked = false,
62+
ChildItems = new ObservableCollection<INavigationControlItem>()
63+
};
64+
MainPage.SideBarItems.Add(section);
65+
}
6466

6567
foreach (StorageFolder folder in await distroFolder.GetFoldersAsync())
6668
{
@@ -90,12 +92,15 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
9092
logoURI = new Uri("ms-appx:///Assets/WSL/genericpng.png");
9193
}
9294

93-
section.ChildItems.Add(new WSLDistroItem()
95+
if (!section.ChildItems.Any(x => x.Path == folder.Path))
9496
{
95-
Text = folder.DisplayName,
96-
Path = folder.Path,
97-
Logo = logoURI
98-
});
97+
section.ChildItems.Add(new WSLDistroItem()
98+
{
99+
Text = folder.DisplayName,
100+
Path = folder.Path,
101+
Logo = logoURI
102+
});
103+
}
99104
}
100105
}
101106
}

0 commit comments

Comments
 (0)