Skip to content

Commit 35f6f00

Browse files
tsvietOKADeltaXt-k365yaira2
authored
Fix drives loading (#701)
Co-authored-by: ADeltaX <adeltaxsystem@gmail.com> Co-authored-by: Thomas <Thomas.Klemenc@gmail.com> Co-authored-by: Yair Aichenbaum <39923744+yaichenbaum@users.noreply.github.com>
1 parent 6eaa0a5 commit 35f6f00

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

Files/Filesystem/Drives.cs

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Collections.ObjectModel;
44
using System.Diagnostics;
@@ -51,37 +51,25 @@ public DrivesManager()
5151
});
5252
}
5353

54-
private async void DeviceWatcher_EnumerationCompleted(DeviceWatcher sender, object args)
54+
private void DeviceWatcher_EnumerationCompleted(DeviceWatcher sender, object args)
5555
{
56-
// Only update collection from UI-thread
57-
try
56+
if (App.sideBarItems.FirstOrDefault(x => x is HeaderTextItem && x.Text == ResourceController.GetTranslation("SidebarDrives")) == null)
57+
{
58+
App.sideBarItems.Add(new HeaderTextItem() { Text = ResourceController.GetTranslation("SidebarDrives") });
59+
}
60+
foreach (DriveItem drive in Drives)
5861
{
59-
await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
62+
if (!App.sideBarItems.Contains(drive))
6063
{
61-
if (App.sideBarItems.FirstOrDefault(x => x is HeaderTextItem && x.Text == ResourceController.GetTranslation("SidebarDrives")) == null)
62-
{
63-
App.sideBarItems.Add(new HeaderTextItem() { Text = ResourceController.GetTranslation("SidebarDrives") });
64-
}
65-
foreach (DriveItem drive in Drives)
66-
{
67-
if (!App.sideBarItems.Contains(drive))
68-
{
69-
App.sideBarItems.Add(drive);
70-
}
71-
}
72-
73-
foreach (INavigationControlItem item in App.sideBarItems.ToList())
74-
{
75-
if (item is DriveItem && !Drives.Contains(item))
76-
{
77-
App.sideBarItems.Remove(item);
78-
}
79-
}
80-
});
64+
App.sideBarItems.Add(drive);
65+
}
8166
}
82-
catch (Exception)
67+
foreach (INavigationControlItem item in App.sideBarItems.ToList())
8368
{
84-
// UI thread not created yet?
69+
if (item is DriveItem && !Drives.Contains(item))
70+
{
71+
App.sideBarItems.Remove(item);
72+
}
8573
}
8674
}
8775

Files/MultilingualResources/Files.es-ES.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,4 +633,4 @@
633633
</group>
634634
</body>
635635
</file>
636-
</xliff>
636+
</xliff>

0 commit comments

Comments
 (0)