Skip to content

Commit f044481

Browse files
committed
Related cleanups and improvements
1 parent 1beddf8 commit f044481

File tree

5 files changed

+11
-38
lines changed

5 files changed

+11
-38
lines changed

Files UWP/Filesystem/ItemViewModel.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,8 @@ public async void AddItemsToCollectionAsync(string path)
284284
(App.selectedTabInstance.accessibleContentFrame.Content as PhotoAlbum).TextState.isVisible = Visibility.Collapsed;
285285
}
286286

287-
_filesAndFolders.Clear();
288287
Universal.path = path;
289-
288+
_filesAndFolders.Clear();
290289
Stopwatch stopwatch = new Stopwatch();
291290
stopwatch.Start();
292291

@@ -498,7 +497,11 @@ private async Task AddFolder(StorageFolder folder)
498497

499498
if ((App.selectedTabInstance.accessibleContentFrame.SourcePageType == typeof(GenericFileBrowser)) || (App.selectedTabInstance.accessibleContentFrame.SourcePageType == typeof(PhotoAlbum)))
500499
{
501-
500+
if (_cancellationTokenSource.IsCancellationRequested)
501+
{
502+
isLoadingItems = false;
503+
return;
504+
}
502505
_filesAndFolders.Add(new ListedItem(folder.FolderRelativeId)
503506
{
504507
FileName = folder.Name,
@@ -592,7 +595,11 @@ private async Task AddFile(StorageFile file)
592595

593596
}
594597
}
595-
598+
if (_cancellationTokenSource.IsCancellationRequested)
599+
{
600+
isLoadingItems = false;
601+
return;
602+
}
596603
_filesAndFolders.Add(new ListedItem(file.FolderRelativeId)
597604
{
598605
DotFileExtension = itemFileExtension,
@@ -656,8 +663,6 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
656663
var files = await _fileQueryResult.GetFilesAsync();
657664
var folders = await _folderQueryResult.GetFoldersAsync();
658665

659-
var cancellationTokenSourceCopy = _cancellationTokenSource;
660-
661666
// modifying a file also results in a new unique FolderRelativeId so no need to check for DateModified explicitly
662667

663668
var addedFiles = files.Select(f => f.FolderRelativeId).Except(_filesAndFolders.Select(f => f.FolderRelativeId));

Files UWP/GenericFileBrowser.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
113113

114114
Clipboard_ContentChanged(null, null);
115115
tabInstance.AlwaysPresentCommands.isEnabled = true;
116-
tabInstance.instanceViewModel.CancelLoadAndClearFiles();
117116
tabInstance.AddItemButton.Click += AddItem_Click;
118117

119118
TextState.isVisible = Visibility.Collapsed;

Files UWP/Interacts/Interaction.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public async void List_ItemClick(object sender, DoubleTappedRoutedEventArgs e)
6363
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).TextState.isVisible = Visibility.Collapsed;
6464
}
6565
tabInstance.FS.isEnabled = false;
66-
tabInstance.instanceViewModel.CancelLoadAndClearFiles();
6766
if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
6867
{
6968
tabInstance.PathText.Text = "Desktop";
@@ -156,7 +155,6 @@ public async void List_ItemClick(object sender, DoubleTappedRoutedEventArgs e)
156155
tabInstance.instanceViewModel.Universal.path = clickedOnItem.FilePath;
157156
tabInstance.PathText.Text = clickedOnItem.FilePath;
158157
tabInstance.FS.isEnabled = false;
159-
tabInstance.instanceViewModel.CancelLoadAndClearFiles();
160158
if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
161159
{
162160
tabInstance.PathText.Text = "Desktop";
@@ -425,7 +423,6 @@ public async void OpenItem_Click(object sender, RoutedEventArgs e)
425423
(tabInstance.accessibleContentFrame.Content as PhotoAlbum).TextState.isVisible = Visibility.Collapsed;
426424
}
427425
tabInstance.FS.isEnabled = false;
428-
tabInstance.instanceViewModel.CancelLoadAndClearFiles();
429426
if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
430427
{
431428
tabInstance.PathText.Text = "Desktop";
@@ -518,7 +515,6 @@ public async void OpenItem_Click(object sender, RoutedEventArgs e)
518515
tabInstance.instanceViewModel.Universal.path = clickedOnItem.FilePath;
519516
tabInstance.PathText.Text = clickedOnItem.FilePath;
520517
tabInstance.FS.isEnabled = false;
521-
tabInstance.instanceViewModel.CancelLoadAndClearFiles();
522518
if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
523519
{
524520
tabInstance.PathText.Text = "Desktop";

Files UWP/PhotoAlbum.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
8585
tabInstance.AlwaysPresentCommands.isEnabled = true;
8686

8787
TextState.isVisible = Visibility.Collapsed;
88-
tabInstance.instanceViewModel.CancelLoadAndClearFiles();
8988

9089
tabInstance.instanceViewModel.AddItemsToCollectionAsync(parameters);
9190

Files UWP/ProHome.xaml.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ public async void CheckPathInput(ItemViewModel instance, string CurrentInput)
360360
{
361361
if (CurrentInput != instance.Universal.path)
362362
{
363-
instance.CancelLoadAndClearFiles();
364363
HomeItems.isEnabled = false;
365364
ShareItems.isEnabled = false;
366365

@@ -525,7 +524,6 @@ public async void CheckPathInput(ItemViewModel instance, string CurrentInput)
525524
private void LocationsList_ItemClick(object sender, ItemClickEventArgs e)
526525
{
527526
ListViewItem clickedItem = Interaction.FindParent<ListViewItem>(e.ClickedItem as DependencyObject);
528-
instanceViewModel.CancelLoadAndClearFiles();
529527

530528
if (clickedItem.Tag.ToString() == "Favorites")
531529
{
@@ -639,7 +637,6 @@ private void DrivesList_ItemClick(object sender, ItemClickEventArgs e)
639637
if (this.accessibleContentFrame.SourcePageType == typeof(GenericFileBrowser))
640638
{
641639
var instance = instanceViewModel;
642-
instance.CancelLoadAndClearFiles();
643640
HomeItems.isEnabled = false;
644641
ShareItems.isEnabled = false;
645642
if (LocationsList.SelectedItem != null)
@@ -703,7 +700,6 @@ private void DrivesList_ItemClick(object sender, ItemClickEventArgs e)
703700
else if (this.accessibleContentFrame.SourcePageType == typeof(PhotoAlbum))
704701
{
705702
var instance = instanceViewModel;
706-
instance.CancelLoadAndClearFiles();
707703
HomeItems.isEnabled = false;
708704
ShareItems.isEnabled = false;
709705
if (LocationsList.SelectedItem != null)
@@ -972,11 +968,6 @@ private void ItemDisplayFrame_Navigated(object sender, Windows.UI.Xaml.Navigatio
972968
instanceViewModel = new ItemViewModel();
973969
instanceInteraction = new Interaction();
974970
}
975-
else if(instanceViewModel != null && instanceInteraction != null)
976-
{
977-
instanceViewModel.CancelLoadAndClearFiles();
978-
}
979-
980971
}
981972

982973
private void HideFakeDialogButton_Click(object sender, RoutedEventArgs e)
@@ -999,14 +990,6 @@ private void PathViewInteract_ItemClick(object sender, ItemClickEventArgs e)
999990
{
1000991
var itemTappedPath = (e.ClickedItem as PathBoxItem).Path.ToString();
1001992
if (itemTappedPath == "Favorites") { return; }
1002-
if ((App.selectedTabInstance.accessibleContentFrame.Content as GenericFileBrowser) != null)
1003-
{
1004-
instanceViewModel.CancelLoadAndClearFiles();
1005-
}
1006-
else if ((App.selectedTabInstance.accessibleContentFrame.Content as PhotoAlbum) != null)
1007-
{
1008-
instanceViewModel.CancelLoadAndClearFiles();
1009-
}
1010993

1011994
App.selectedTabInstance.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), itemTappedPath, new SuppressNavigationTransitionInfo());
1012995
}
@@ -1024,7 +1007,6 @@ public async static void Refresh_Click(object sender, RoutedEventArgs e)
10241007
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
10251008
{
10261009
var ContentOwnedViewModelInstance = App.selectedTabInstance.instanceViewModel;
1027-
ContentOwnedViewModelInstance.CancelLoadAndClearFiles();
10281010
ContentOwnedViewModelInstance.AddItemsToCollectionAsync(ContentOwnedViewModelInstance.Universal.path);
10291011
});
10301012
}
@@ -1036,7 +1018,6 @@ public static void Back_Click(object sender, RoutedEventArgs e)
10361018
if ((App.selectedTabInstance.accessibleContentFrame.Content as GenericFileBrowser) != null)
10371019
{
10381020
var instanceContent = (instanceContentFrame.Content as GenericFileBrowser);
1039-
App.selectedTabInstance.instanceViewModel.CancelLoadAndClearFiles();
10401021
if (instanceContentFrame.CanGoBack)
10411022
{
10421023
var previousSourcePageType = instanceContentFrame.BackStack[instanceContentFrame.BackStack.Count - 1].SourcePageType;
@@ -1113,7 +1094,6 @@ public static void Back_Click(object sender, RoutedEventArgs e)
11131094
else if ((App.selectedTabInstance.accessibleContentFrame.Content as PhotoAlbum) != null)
11141095
{
11151096
var instanceContent = (instanceContentFrame.Content as PhotoAlbum);
1116-
App.selectedTabInstance.instanceViewModel.CancelLoadAndClearFiles();
11171097
if (instanceContentFrame.CanGoBack)
11181098
{
11191099
var previousSourcePageType = instanceContentFrame.BackStack[instanceContentFrame.BackStack.Count - 1].SourcePageType;
@@ -1190,7 +1170,6 @@ public static void Back_Click(object sender, RoutedEventArgs e)
11901170
else if ((App.selectedTabInstance.accessibleContentFrame.Content as YourHome) != null)
11911171
{
11921172
var instanceContent = (instanceContentFrame.Content as YourHome);
1193-
App.selectedTabInstance.instanceViewModel.CancelLoadAndClearFiles();
11941173

11951174
if (instanceContentFrame.CanGoBack)
11961175
{
@@ -1274,7 +1253,6 @@ public static void Forward_Click(object sender, RoutedEventArgs e)
12741253
if ((App.selectedTabInstance.accessibleContentFrame.Content as GenericFileBrowser) != null)
12751254
{
12761255
var instanceContent = (instanceContentFrame.Content as GenericFileBrowser);
1277-
App.selectedTabInstance.instanceViewModel.CancelLoadAndClearFiles();
12781256

12791257
if (instanceContentFrame.CanGoForward)
12801258
{
@@ -1353,7 +1331,6 @@ public static void Forward_Click(object sender, RoutedEventArgs e)
13531331
{
13541332
var instance = App.selectedTabInstance.instanceViewModel;
13551333
var instanceContent = (instanceContentFrame.Content as PhotoAlbum);
1356-
instance.CancelLoadAndClearFiles();
13571334

13581335
if (instanceContentFrame.CanGoForward)
13591336
{
@@ -1431,7 +1408,6 @@ public static void Forward_Click(object sender, RoutedEventArgs e)
14311408
else if ((App.selectedTabInstance.accessibleContentFrame.Content as YourHome) != null)
14321409
{
14331410
var instanceContent = (instanceContentFrame.Content as YourHome);
1434-
App.selectedTabInstance.instanceViewModel.CancelLoadAndClearFiles();
14351411

14361412
if (instanceContentFrame.CanGoForward)
14371413
{
@@ -1515,7 +1491,6 @@ public static void Up_Click(object sender, RoutedEventArgs e)
15151491
if ((instanceContentFrame.Content as GenericFileBrowser) != null)
15161492
{
15171493
var instance = App.selectedTabInstance.instanceViewModel;
1518-
instance.CancelLoadAndClearFiles();
15191494
string parentDirectoryOfPath = null;
15201495
// Check that there isn't a slash at the end
15211496
if((instance.Universal.path.Count() - 1) - instance.Universal.path.LastIndexOf("\\") > 0)
@@ -1592,7 +1567,6 @@ public static void Up_Click(object sender, RoutedEventArgs e)
15921567
else if ((instanceContentFrame.Content as PhotoAlbum) != null)
15931568
{
15941569
var instance = App.selectedTabInstance.instanceViewModel;
1595-
instance.CancelLoadAndClearFiles();
15961570
string parentDirectoryOfPath = null;
15971571
// Check that there isn't a slash at the end
15981572
if ((instance.Universal.path.Count() - 1) - instance.Universal.path.LastIndexOf("\\") > 0)

0 commit comments

Comments
 (0)