Skip to content

Commit 3191f66

Browse files
committed
refactor folder and files addition
1 parent 256a881 commit 3191f66

File tree

6 files changed

+208
-237
lines changed

6 files changed

+208
-237
lines changed

Files UWP/Filesystem/ItemViewModel.cs

Lines changed: 190 additions & 216 deletions
Large diffs are not rendered by default.

Files UWP/GenericFileBrowser.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,9 @@ private async void VisiblePath_TextChanged(object sender, KeyRoutedEventArgs e)
332332
var CurrentInput = PathBox.Text;
333333
if (CurrentInput != App.ViewModel.Universal.path)
334334
{
335-
if (App.ViewModel.tokenSource != null)
335+
if (!App.ViewModel.TokenSource.IsCancellationRequested)
336336
{
337-
App.ViewModel.tokenSource.Cancel();
337+
App.ViewModel.TokenSource.Cancel();
338338
App.ViewModel.FilesAndFolders.Clear();
339339
}
340340

Files UWP/MainPage.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ private void NavView_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
151151
}
152152
else
153153
{
154-
if(App.ViewModel.tokenSource != null)
154+
if (!App.ViewModel.TokenSource.IsCancellationRequested)
155155
{
156-
App.ViewModel.tokenSource.Cancel();
156+
App.ViewModel.TokenSource.Cancel();
157157
App.ViewModel.FilesAndFolders.Clear();
158158
}
159159
App.ViewModel.TextState.isVisible = Visibility.Collapsed;

Files UWP/Navigation/NavigationActions.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public class NavigationActions
1111
{
1212
public static void Back_Click(object sender, RoutedEventArgs e)
1313
{
14-
if(App.ViewModel.tokenSource != null)
14+
if (!App.ViewModel.TokenSource.IsCancellationRequested)
1515
{
16-
App.ViewModel.tokenSource.Cancel();
16+
App.ViewModel.TokenSource.Cancel();
1717
}
1818
App.ViewModel.FilesAndFolders.Clear();
1919

@@ -160,13 +160,11 @@ public static void Back_Click(object sender, RoutedEventArgs e)
160160

161161
public static void Forward_Click(object sender, RoutedEventArgs e)
162162
{
163-
164-
if(App.ViewModel.tokenSource != null)
163+
if (!App.ViewModel.TokenSource.IsCancellationRequested)
165164
{
166-
App.ViewModel.tokenSource.Cancel();
165+
App.ViewModel.TokenSource.Cancel();
167166
}
168167
App.ViewModel.FilesAndFolders.Clear();
169-
170168

171169
if (History.ForwardList.Count() > 0)
172170
{
@@ -313,9 +311,9 @@ public async static void Refresh_Click(object sender, RoutedEventArgs e)
313311
{
314312
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
315313
{
316-
if(App.ViewModel.tokenSource != null)
314+
if (!App.ViewModel.TokenSource.IsCancellationRequested)
317315
{
318-
App.ViewModel.tokenSource.Cancel();
316+
App.ViewModel.TokenSource.Cancel();
319317
}
320318
App.ViewModel.TextState.isVisible = Visibility.Collapsed;
321319
App.ViewModel.FilesAndFolders.Clear();

Files UWP/Navigation/PhotoAlbumNavActions.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ public class PhotoAlbumNavActions
1313
{
1414
public static void Back_Click(object sender, RoutedEventArgs e)
1515
{
16-
17-
if(App.ViewModel.tokenSource != null)
16+
if (!App.ViewModel.TokenSource.IsCancellationRequested)
1817
{
19-
App.ViewModel.tokenSource.Cancel();
18+
App.ViewModel.TokenSource.Cancel();
2019
}
2120
App.ViewModel.FilesAndFolders.Clear();
2221

@@ -161,9 +160,9 @@ public static void Back_Click(object sender, RoutedEventArgs e)
161160

162161
public static void Forward_Click(object sender, RoutedEventArgs e)
163162
{
164-
if(App.ViewModel.tokenSource != null)
163+
if (!App.ViewModel.TokenSource.IsCancellationRequested)
165164
{
166-
App.ViewModel.tokenSource.Cancel();
165+
App.ViewModel.TokenSource.Cancel();
167166
}
168167
App.ViewModel.FilesAndFolders.Clear();
169168

@@ -311,9 +310,9 @@ public async static void Refresh_Click(object sender, RoutedEventArgs e)
311310
{
312311
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
313312
{
314-
if(App.ViewModel.tokenSource != null)
313+
if (!App.ViewModel.TokenSource.IsCancellationRequested)
315314
{
316-
App.ViewModel.tokenSource.Cancel();
315+
App.ViewModel.TokenSource.Cancel();
317316
}
318317
App.ViewModel.TextState.isVisible = Visibility.Collapsed;
319318
App.ViewModel.FilesAndFolders.Clear();

Files UWP/PhotoAlbum.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ private async void VisiblePath_TextChanged(object sender, KeyRoutedEventArgs e)
129129
var CurrentInput = PathBox.Text;
130130
if (CurrentInput != App.ViewModel.Universal.path)
131131
{
132-
if (App.ViewModel.tokenSource != null)
132+
if (!App.ViewModel.TokenSource.IsCancellationRequested)
133133
{
134-
App.ViewModel.tokenSource.Cancel();
134+
App.ViewModel.TokenSource.Cancel();
135135
App.ViewModel.FilesAndFolders.Clear();
136136
}
137137

0 commit comments

Comments
 (0)