Skip to content

Commit 8d23842

Browse files
authored
Hide network section in sidebar when no drives are detected (#4120)
1 parent ca7e4da commit 8d23842

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Files/Filesystem/NetworkDrivesManager.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public NetworkDrivesManager()
3535
{
3636
var networkItem = new DriveItem()
3737
{
38+
DeviceID = "network-folder",
3839
Text = "Network".GetLocalized(),
3940
Path = App.AppSettings.NetworkFolderPath,
4041
Type = DriveType.Network,
@@ -112,7 +113,7 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
112113
MainPage.SideBarItems.BeginBulkOperation();
113114

114115
var section = MainPage.SideBarItems.FirstOrDefault(x => x.Text == "SidebarNetworkDrives".GetLocalized()) as LocationItem;
115-
if (section == null)
116+
if (section == null && this.drivesList.Any(d => d.DeviceID != "network-folder"))
116117
{
117118
section = new LocationItem()
118119
{
@@ -125,13 +126,16 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
125126
MainPage.SideBarItems.Add(section);
126127
}
127128

128-
foreach (var drive in Drives.ToList()
129+
if (section != null)
130+
{
131+
foreach (var drive in Drives.ToList()
129132
.OrderByDescending(o => string.Equals(o.Text, "Network".GetLocalized(), StringComparison.OrdinalIgnoreCase))
130133
.ThenBy(o => o.Text))
131-
{
132-
if (!section.ChildItems.Contains(drive))
133134
{
134-
section.ChildItems.Add(drive);
135+
if (!section.ChildItems.Contains(drive))
136+
{
137+
section.ChildItems.Add(drive);
138+
}
135139
}
136140
}
137141

0 commit comments

Comments
 (0)