Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/Files.App/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public GitProperties EnabledGitProperties
private CancellationTokenSource watcherCTS;
private CancellationTokenSource searchCTS;
private CancellationTokenSource updateTagGroupCTS;
private CancellationTokenSource? filterDebounceCS;

public event EventHandler FocusFilterHeader;

Expand Down Expand Up @@ -789,7 +790,20 @@ public string? FilesAndFoldersFilter

private void FilesAndFolderFilterUpdated()
{
_ = ApplyFilesAndFoldersChangesAsync();
if (filterDebounceCS is not null)
{
filterDebounceCS.Cancel();
filterDebounceCS.Dispose();
}

filterDebounceCS = new CancellationTokenSource();
var token = filterDebounceCS.Token;

_ = Task.Delay(250, token)
.ContinueWith(_ => ApplyFilesAndFoldersChangesAsync(), token,
TaskContinuationOptions.OnlyOnRanToCompletion,
TaskScheduler.Default)
.Unwrap();
}


Expand Down Expand Up @@ -2796,6 +2810,8 @@ public void UpdateDateDisplay(bool isFormatChange)
public void Dispose()
{
CancelLoadAndClearFiles();
filterDebounceCS?.Cancel();
filterDebounceCS?.Dispose();
App.Logger.LogInformation($"ShellViewModel.Dispose: CurrentFolder={LogPathHelper.GetPathIdentifier(CurrentFolder?.ItemPath)}");

StorageTrashBinService.Watcher.ItemAdded -= RecycleBinItemCreatedAsync;
Expand Down
Loading