From 4085fff141d35ff9acd34dead652ea9e0ed2c0b9 Mon Sep 17 00:00:00 2001 From: Jerrod Estell Date: Tue, 19 Sep 2023 10:40:24 -0700 Subject: [PATCH 1/5] OpenNewPaneAction limited to 800ms and deliberate key strokes --- .../Actions/Navigation/OpenNewPaneAction.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs b/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs index 1c4e2209ddc7..957e1a2875b5 100644 --- a/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs +++ b/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs @@ -5,6 +5,10 @@ namespace Files.App.Actions { internal class OpenNewPaneAction : ObservableObject, IAction { + private DateTime lastExecuted = DateTime.MinValue; + + private readonly TimeSpan debounceTime = TimeSpan.FromMilliseconds(800); + private readonly IContentPageContext context; public string Label @@ -35,6 +39,18 @@ public OpenNewPaneAction() public Task ExecuteAsync() { + DateTime now = DateTime.Now; + + if (now - lastExecuted < debounceTime) + { + // Too soon since the last execution, return immediately + return Task.CompletedTask; + } + + // Record the current execution time + lastExecuted = now; + + // Existing logic context.ShellPage!.PaneHolder.OpenPathInNewPane("Home"); return Task.CompletedTask; From d2365323f6d34b40f4a81e4353e642791cbc9ce0 Mon Sep 17 00:00:00 2001 From: Jerrod Estell Date: Tue, 19 Sep 2023 10:57:07 -0700 Subject: [PATCH 2/5] RefreshItemsAction and ClosePaneAction revised for deliberate action rather than continuous action upon button press --- .../Actions/Content/RefreshItemsAction.cs | 14 ++++++++++++++ .../Actions/Navigation/ClosePaneAction.cs | 13 +++++++++++++ .../Actions/Navigation/OpenNewPaneAction.cs | 2 -- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Files.App/Actions/Content/RefreshItemsAction.cs b/src/Files.App/Actions/Content/RefreshItemsAction.cs index 5f7c1dfcd8dc..8392c4d1750e 100644 --- a/src/Files.App/Actions/Content/RefreshItemsAction.cs +++ b/src/Files.App/Actions/Content/RefreshItemsAction.cs @@ -5,6 +5,10 @@ namespace Files.App.Actions { internal class RefreshItemsAction : ObservableObject, IAction { + private DateTime lastExecuted = DateTime.MinValue; + + private readonly TimeSpan debounceTime = TimeSpan.FromMilliseconds(800); + private readonly IContentPageContext context; public string Label @@ -34,6 +38,16 @@ public RefreshItemsAction() public async Task ExecuteAsync() { + DateTime now = DateTime.Now; + + if (now - lastExecuted < debounceTime) + { + // Too soon since the last execution, return immediately + return; + } + + lastExecuted = now; + context.ShellPage?.Refresh_Click(); } diff --git a/src/Files.App/Actions/Navigation/ClosePaneAction.cs b/src/Files.App/Actions/Navigation/ClosePaneAction.cs index 7559b83c8755..61c27aaca8c8 100644 --- a/src/Files.App/Actions/Navigation/ClosePaneAction.cs +++ b/src/Files.App/Actions/Navigation/ClosePaneAction.cs @@ -5,6 +5,10 @@ namespace Files.App.Actions { internal class ClosePaneAction : ObservableObject, IAction { + private DateTime lastExecuted = DateTime.MinValue; + + private readonly TimeSpan debounceTime = TimeSpan.FromMilliseconds(800); + private readonly IContentPageContext context; public string Label @@ -31,6 +35,15 @@ public ClosePaneAction() public Task ExecuteAsync() { + DateTime now = DateTime.Now; + + if (now - lastExecuted < debounceTime) // Execute only if enough time has passed since the last execution + { + return Task.CompletedTask; + } + + lastExecuted = now; + context.ShellPage!.PaneHolder.CloseActivePane(); return Task.CompletedTask; diff --git a/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs b/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs index 957e1a2875b5..57ec4ed69ec2 100644 --- a/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs +++ b/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs @@ -47,10 +47,8 @@ public Task ExecuteAsync() return Task.CompletedTask; } - // Record the current execution time lastExecuted = now; - // Existing logic context.ShellPage!.PaneHolder.OpenPathInNewPane("Home"); return Task.CompletedTask; From 0b5092f2816d29060cb84c6f4e56ba59e038a262 Mon Sep 17 00:00:00 2001 From: Jerrod Estell Date: Tue, 10 Oct 2023 17:23:06 -0700 Subject: [PATCH 3/5] DebounceAction class, DebounceAction decorator implemented. Debounce decorator applied to all actions. --- .../Actions/Content/RefreshItemsAction.cs | 14 - src/Files.App/Actions/DebounceAction.cs | 40 +++ .../Actions/DebouncedActionDecorator.cs | 40 +++ .../Actions/Navigation/ClosePaneAction.cs | 13 - .../Actions/Navigation/OpenNewPaneAction.cs | 14 - .../Data/Commands/Manager/CommandManager.cs | 286 +++++++++--------- 6 files changed, 223 insertions(+), 184 deletions(-) create mode 100644 src/Files.App/Actions/DebounceAction.cs create mode 100644 src/Files.App/Actions/DebouncedActionDecorator.cs diff --git a/src/Files.App/Actions/Content/RefreshItemsAction.cs b/src/Files.App/Actions/Content/RefreshItemsAction.cs index 8392c4d1750e..5f7c1dfcd8dc 100644 --- a/src/Files.App/Actions/Content/RefreshItemsAction.cs +++ b/src/Files.App/Actions/Content/RefreshItemsAction.cs @@ -5,10 +5,6 @@ namespace Files.App.Actions { internal class RefreshItemsAction : ObservableObject, IAction { - private DateTime lastExecuted = DateTime.MinValue; - - private readonly TimeSpan debounceTime = TimeSpan.FromMilliseconds(800); - private readonly IContentPageContext context; public string Label @@ -38,16 +34,6 @@ public RefreshItemsAction() public async Task ExecuteAsync() { - DateTime now = DateTime.Now; - - if (now - lastExecuted < debounceTime) - { - // Too soon since the last execution, return immediately - return; - } - - lastExecuted = now; - context.ShellPage?.Refresh_Click(); } diff --git a/src/Files.App/Actions/DebounceAction.cs b/src/Files.App/Actions/DebounceAction.cs new file mode 100644 index 000000000000..abb7e56b002f --- /dev/null +++ b/src/Files.App/Actions/DebounceAction.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Files.App.Actions +{ + public abstract class DebouncedAction : IAction + { + private DateTime lastExecuted = DateTime.MinValue; + private readonly TimeSpan debounceTime; + + protected DebouncedAction(TimeSpan debounceDuration) + { + debounceTime = debounceDuration; + } + + public virtual bool CanExecuteNow() + { + return DateTime.Now - lastExecuted > debounceTime; + } + + public virtual void MarkAsExecuted() + { + lastExecuted = DateTime.Now; + } + + public abstract string Label { get; } + public abstract string Description { get; } + public abstract RichGlyph Glyph { get; } + public abstract HotKey HotKey { get; } + public abstract HotKey SecondHotKey { get; } + public abstract HotKey ThirdHotKey { get; } + public abstract HotKey MediaHotKey { get; } + public abstract bool IsExecutable { get; } + + public abstract Task ExecuteAsync(); + } +} \ No newline at end of file diff --git a/src/Files.App/Actions/DebouncedActionDecorator.cs b/src/Files.App/Actions/DebouncedActionDecorator.cs new file mode 100644 index 000000000000..2e5fa6ac7dea --- /dev/null +++ b/src/Files.App/Actions/DebouncedActionDecorator.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Files.App.Actions +{ + public class DebouncedActionDecorator : DebouncedAction + { + private readonly IAction _innerAction; + + public DebouncedActionDecorator(IAction innerAction, TimeSpan debounceDuration) + : base(debounceDuration) + { + _innerAction = innerAction; + } + + public override string Label => _innerAction.Label; + public override string Description => _innerAction.Description; + public override RichGlyph Glyph => _innerAction.Glyph; + public override HotKey HotKey => _innerAction.HotKey; + public override HotKey SecondHotKey => _innerAction.SecondHotKey; + public override HotKey ThirdHotKey => _innerAction.ThirdHotKey; + public override HotKey MediaHotKey => _innerAction.MediaHotKey; + public override bool IsExecutable => _innerAction.IsExecutable; + + public override async Task ExecuteAsync() + { + if (!CanExecuteNow()) + { + return; + } + + MarkAsExecuted(); + + await _innerAction.ExecuteAsync(); + } + } +} diff --git a/src/Files.App/Actions/Navigation/ClosePaneAction.cs b/src/Files.App/Actions/Navigation/ClosePaneAction.cs index 61c27aaca8c8..7559b83c8755 100644 --- a/src/Files.App/Actions/Navigation/ClosePaneAction.cs +++ b/src/Files.App/Actions/Navigation/ClosePaneAction.cs @@ -5,10 +5,6 @@ namespace Files.App.Actions { internal class ClosePaneAction : ObservableObject, IAction { - private DateTime lastExecuted = DateTime.MinValue; - - private readonly TimeSpan debounceTime = TimeSpan.FromMilliseconds(800); - private readonly IContentPageContext context; public string Label @@ -35,15 +31,6 @@ public ClosePaneAction() public Task ExecuteAsync() { - DateTime now = DateTime.Now; - - if (now - lastExecuted < debounceTime) // Execute only if enough time has passed since the last execution - { - return Task.CompletedTask; - } - - lastExecuted = now; - context.ShellPage!.PaneHolder.CloseActivePane(); return Task.CompletedTask; diff --git a/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs b/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs index 57ec4ed69ec2..1c4e2209ddc7 100644 --- a/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs +++ b/src/Files.App/Actions/Navigation/OpenNewPaneAction.cs @@ -5,10 +5,6 @@ namespace Files.App.Actions { internal class OpenNewPaneAction : ObservableObject, IAction { - private DateTime lastExecuted = DateTime.MinValue; - - private readonly TimeSpan debounceTime = TimeSpan.FromMilliseconds(800); - private readonly IContentPageContext context; public string Label @@ -39,16 +35,6 @@ public OpenNewPaneAction() public Task ExecuteAsync() { - DateTime now = DateTime.Now; - - if (now - lastExecuted < debounceTime) - { - // Too soon since the last execution, return immediately - return Task.CompletedTask; - } - - lastExecuted = now; - context.ShellPage!.PaneHolder.OpenPathInNewPane("Home"); return Task.CompletedTask; diff --git a/src/Files.App/Data/Commands/Manager/CommandManager.cs b/src/Files.App/Data/Commands/Manager/CommandManager.cs index b8467816a643..67e3dee05bda 100644 --- a/src/Files.App/Data/Commands/Manager/CommandManager.cs +++ b/src/Files.App/Data/Commands/Manager/CommandManager.cs @@ -199,149 +199,149 @@ public CommandManager() private static IDictionary CreateActions() => new Dictionary { - [CommandCodes.OpenHelp] = new OpenHelpAction(), - [CommandCodes.ToggleFullScreen] = new ToggleFullScreenAction(), - [CommandCodes.EnterCompactOverlay] = new EnterCompactOverlayAction(), - [CommandCodes.ExitCompactOverlay] = new ExitCompactOverlayAction(), - [CommandCodes.ToggleCompactOverlay] = new ToggleCompactOverlayAction(), - [CommandCodes.Search] = new SearchAction(), - [CommandCodes.SearchUnindexedItems] = new SearchUnindexedItemsAction(), - [CommandCodes.EditPath] = new EditPathAction(), - [CommandCodes.Redo] = new RedoAction(), - [CommandCodes.Undo] = new UndoAction(), - [CommandCodes.ToggleShowHiddenItems] = new ToggleShowHiddenItemsAction(), - [CommandCodes.ToggleShowFileExtensions] = new ToggleShowFileExtensionsAction(), - [CommandCodes.TogglePreviewPane] = new TogglePreviewPaneAction(), - [CommandCodes.SelectAll] = new SelectAllAction(), - [CommandCodes.InvertSelection] = new InvertSelectionAction(), - [CommandCodes.ClearSelection] = new ClearSelectionAction(), - [CommandCodes.ToggleSelect] = new ToggleSelectAction(), - [CommandCodes.ShareItem] = new ShareItemAction(), - [CommandCodes.EmptyRecycleBin] = new EmptyRecycleBinAction(), - [CommandCodes.RestoreRecycleBin] = new RestoreRecycleBinAction(), - [CommandCodes.RestoreAllRecycleBin] = new RestoreAllRecycleBinAction(), - [CommandCodes.RefreshItems] = new RefreshItemsAction(), - [CommandCodes.Rename] = new RenameAction(), - [CommandCodes.CreateShortcut] = new CreateShortcutAction(), - [CommandCodes.CreateShortcutFromDialog] = new CreateShortcutFromDialogAction(), - [CommandCodes.CreateFolder] = new CreateFolderAction(), - [CommandCodes.CreateFolderWithSelection] = new CreateFolderWithSelectionAction(), - [CommandCodes.AddItem] = new AddItemAction(), - [CommandCodes.PinToStart] = new PinToStartAction(), - [CommandCodes.UnpinFromStart] = new UnpinFromStartAction(), - [CommandCodes.PinItemToFavorites] = new PinItemAction(), - [CommandCodes.UnpinItemFromFavorites] = new UnpinItemAction(), - [CommandCodes.SetAsWallpaperBackground] = new SetAsWallpaperBackgroundAction(), - [CommandCodes.SetAsSlideshowBackground] = new SetAsSlideshowBackgroundAction(), - [CommandCodes.SetAsLockscreenBackground] = new SetAsLockscreenBackgroundAction(), - [CommandCodes.CopyItem] = new CopyItemAction(), - [CommandCodes.CopyPath] = new CopyPathAction(), - [CommandCodes.CutItem] = new CutItemAction(), - [CommandCodes.PasteItem] = new PasteItemAction(), - [CommandCodes.PasteItemToSelection] = new PasteItemToSelectionAction(), - [CommandCodes.DeleteItem] = new DeleteItemAction(), - [CommandCodes.DeleteItemPermanently] = new DeleteItemPermanentlyAction(), - [CommandCodes.InstallFont] = new InstallFontAction(), - [CommandCodes.InstallInfDriver] = new InstallInfDriverAction(), - [CommandCodes.InstallCertificate] = new InstallCertificateAction(), - [CommandCodes.RunAsAdmin] = new RunAsAdminAction(), - [CommandCodes.RunAsAnotherUser] = new RunAsAnotherUserAction(), - [CommandCodes.RunWithPowershell] = new RunWithPowershellAction(), - [CommandCodes.LaunchPreviewPopup] = new LaunchPreviewPopupAction(), - [CommandCodes.CompressIntoArchive] = new CompressIntoArchiveAction(), - [CommandCodes.CompressIntoSevenZip] = new CompressIntoSevenZipAction(), - [CommandCodes.CompressIntoZip] = new CompressIntoZipAction(), - [CommandCodes.DecompressArchive] = new DecompressArchive(), - [CommandCodes.DecompressArchiveHere] = new DecompressArchiveHere(), - [CommandCodes.DecompressArchiveToChildFolder] = new DecompressArchiveToChildFolderAction(), - [CommandCodes.RotateLeft] = new RotateLeftAction(), - [CommandCodes.RotateRight] = new RotateRightAction(), - [CommandCodes.OpenItem] = new OpenItemAction(), - [CommandCodes.OpenItemWithApplicationPicker] = new OpenItemWithApplicationPickerAction(), - [CommandCodes.OpenParentFolder] = new OpenParentFolderAction(), - [CommandCodes.OpenInVS] = new OpenInVSAction(), - [CommandCodes.OpenInVSCode] = new OpenInVSCodeAction(), - [CommandCodes.OpenProperties] = new OpenPropertiesAction(), - [CommandCodes.OpenSettings] = new OpenSettingsAction(), - [CommandCodes.OpenTerminal] = new OpenTerminalAction(), - [CommandCodes.OpenTerminalAsAdmin] = new OpenTerminalAsAdminAction(), - [CommandCodes.OpenCommandPalette] = new OpenCommandPaletteAction(), - [CommandCodes.LayoutDecreaseSize] = new LayoutDecreaseSizeAction(), - [CommandCodes.LayoutIncreaseSize] = new LayoutIncreaseSizeAction(), - [CommandCodes.LayoutDetails] = new LayoutDetailsAction(), - [CommandCodes.LayoutTiles] = new LayoutTilesAction(), - [CommandCodes.LayoutGridSmall] = new LayoutGridSmallAction(), - [CommandCodes.LayoutGridMedium] = new LayoutGridMediumAction(), - [CommandCodes.LayoutGridLarge] = new LayoutGridLargeAction(), - [CommandCodes.LayoutColumns] = new LayoutColumnsAction(), - [CommandCodes.LayoutAdaptive] = new LayoutAdaptiveAction(), - [CommandCodes.SortByName] = new SortByNameAction(), - [CommandCodes.SortByDateModified] = new SortByDateModifiedAction(), - [CommandCodes.SortByDateCreated] = new SortByDateCreatedAction(), - [CommandCodes.SortBySize] = new SortBySizeAction(), - [CommandCodes.SortByType] = new SortByTypeAction(), - [CommandCodes.SortBySyncStatus] = new SortBySyncStatusAction(), - [CommandCodes.SortByTag] = new SortByTagAction(), - [CommandCodes.SortByPath] = new SortByPathAction(), - [CommandCodes.SortByOriginalFolder] = new SortByOriginalFolderAction(), - [CommandCodes.SortByDateDeleted] = new SortByDateDeletedAction(), - [CommandCodes.SortAscending] = new SortAscendingAction(), - [CommandCodes.SortDescending] = new SortDescendingAction(), - [CommandCodes.ToggleSortDirection] = new ToggleSortDirectionAction(), - [CommandCodes.ToggleSortDirectoriesAlongsideFiles] = new ToggleSortDirectoriesAlongsideFilesAction(), - [CommandCodes.GroupByNone] = new GroupByNoneAction(), - [CommandCodes.GroupByName] = new GroupByNameAction(), - [CommandCodes.GroupByDateModified] = new GroupByDateModifiedAction(), - [CommandCodes.GroupByDateCreated] = new GroupByDateCreatedAction(), - [CommandCodes.GroupBySize] = new GroupBySizeAction(), - [CommandCodes.GroupByType] = new GroupByTypeAction(), - [CommandCodes.GroupBySyncStatus] = new GroupBySyncStatusAction(), - [CommandCodes.GroupByTag] = new GroupByTagAction(), - [CommandCodes.GroupByOriginalFolder] = new GroupByOriginalFolderAction(), - [CommandCodes.GroupByDateDeleted] = new GroupByDateDeletedAction(), - [CommandCodes.GroupByFolderPath] = new GroupByFolderPathAction(), - [CommandCodes.GroupByDateModifiedYear] = new GroupByDateModifiedYearAction(), - [CommandCodes.GroupByDateModifiedMonth] = new GroupByDateModifiedMonthAction(), - [CommandCodes.GroupByDateCreatedYear] = new GroupByDateCreatedYearAction(), - [CommandCodes.GroupByDateCreatedMonth] = new GroupByDateCreatedMonthAction(), - [CommandCodes.GroupByDateDeletedYear] = new GroupByDateDeletedYearAction(), - [CommandCodes.GroupByDateDeletedMonth] = new GroupByDateDeletedMonthAction(), - [CommandCodes.GroupAscending] = new GroupAscendingAction(), - [CommandCodes.GroupDescending] = new GroupDescendingAction(), - [CommandCodes.ToggleGroupDirection] = new ToggleGroupDirectionAction(), - [CommandCodes.GroupByYear] = new GroupByYearAction(), - [CommandCodes.GroupByMonth] = new GroupByMonthAction(), - [CommandCodes.ToggleGroupByDateUnit] = new ToggleGroupByDateUnitAction(), - [CommandCodes.NewTab] = new NewTabAction(), - [CommandCodes.FormatDrive] = new FormatDriveAction(), - [CommandCodes.NavigateBack] = new NavigateBackAction(), - [CommandCodes.NavigateForward] = new NavigateForwardAction(), - [CommandCodes.NavigateUp] = new NavigateUpAction(), - [CommandCodes.DuplicateCurrentTab] = new DuplicateCurrentTabAction(), - [CommandCodes.DuplicateSelectedTab] = new DuplicateSelectedTabAction(), - [CommandCodes.CloseTabsToTheLeftCurrent] = new CloseTabsToTheLeftCurrentAction(), - [CommandCodes.CloseTabsToTheLeftSelected] = new CloseTabsToTheLeftSelectedAction(), - [CommandCodes.CloseTabsToTheRightCurrent] = new CloseTabsToTheRightCurrentAction(), - [CommandCodes.CloseTabsToTheRightSelected] = new CloseTabsToTheRightSelectedAction(), - [CommandCodes.CloseOtherTabsCurrent] = new CloseOtherTabsCurrentAction(), - [CommandCodes.CloseOtherTabsSelected] = new CloseOtherTabsSelectedAction(), - [CommandCodes.OpenDirectoryInNewPane] = new OpenDirectoryInNewPaneAction(), - [CommandCodes.OpenDirectoryInNewTab] = new OpenDirectoryInNewTabAction(), - [CommandCodes.OpenInNewWindowItem] = new OpenInNewWindowItemAction(), - [CommandCodes.ReopenClosedTab] = new ReopenClosedTabAction(), - [CommandCodes.PreviousTab] = new PreviousTabAction(), - [CommandCodes.NextTab] = new NextTabAction(), - [CommandCodes.CloseSelectedTab] = new CloseSelectedTabAction(), - [CommandCodes.OpenNewPane] = new OpenNewPaneAction(), - [CommandCodes.ClosePane] = new ClosePaneAction(), - [CommandCodes.OpenFileLocation] = new OpenFileLocationAction(), - [CommandCodes.PlayAll] = new PlayAllAction(), - [CommandCodes.GitFetch] = new GitFetchAction(), - [CommandCodes.GitInit] = new GitInitAction(), - [CommandCodes.GitPull] = new GitPullAction(), - [CommandCodes.GitPush] = new GitPushAction(), - [CommandCodes.GitSync] = new GitSyncAction(), - [CommandCodes.OpenAllTaggedItems] = new OpenAllTaggedActions(), + [CommandCodes.OpenHelp] = new DebouncedActionDecorator(new OpenHelpAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ToggleFullScreen] = new DebouncedActionDecorator(new ToggleFullScreenAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.EnterCompactOverlay] = new DebouncedActionDecorator(new EnterCompactOverlayAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ExitCompactOverlay] = new DebouncedActionDecorator(new ExitCompactOverlayAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ToggleCompactOverlay] = new DebouncedActionDecorator(new ToggleCompactOverlayAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.Search] = new DebouncedActionDecorator(new SearchAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SearchUnindexedItems] = new DebouncedActionDecorator(new SearchUnindexedItemsAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.EditPath] = new DebouncedActionDecorator(new EditPathAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.Redo] = new DebouncedActionDecorator(new RedoAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.Undo] = new DebouncedActionDecorator(new UndoAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ToggleShowHiddenItems] = new DebouncedActionDecorator(new ToggleShowHiddenItemsAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ToggleShowFileExtensions] = new DebouncedActionDecorator(new ToggleShowFileExtensionsAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.TogglePreviewPane] = new DebouncedActionDecorator(new TogglePreviewPaneAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SelectAll] = new DebouncedActionDecorator(new SelectAllAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.InvertSelection] = new DebouncedActionDecorator(new InvertSelectionAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ClearSelection] = new DebouncedActionDecorator(new ClearSelectionAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ToggleSelect] = new DebouncedActionDecorator(new ToggleSelectAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ShareItem] = new DebouncedActionDecorator(new ShareItemAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.EmptyRecycleBin] = new DebouncedActionDecorator(new EmptyRecycleBinAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.RestoreRecycleBin] = new DebouncedActionDecorator(new RestoreRecycleBinAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.RestoreAllRecycleBin] = new DebouncedActionDecorator(new RestoreAllRecycleBinAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.RefreshItems] = new DebouncedActionDecorator(new RefreshItemsAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.Rename] = new DebouncedActionDecorator(new RenameAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CreateShortcut] = new DebouncedActionDecorator(new CreateShortcutAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CreateShortcutFromDialog] = new DebouncedActionDecorator(new CreateShortcutFromDialogAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CreateFolder] = new DebouncedActionDecorator(new CreateFolderAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CreateFolderWithSelection] = new DebouncedActionDecorator(new CreateFolderWithSelectionAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.AddItem] = new DebouncedActionDecorator(new AddItemAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.PinToStart] = new DebouncedActionDecorator(new PinToStartAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.UnpinFromStart] = new DebouncedActionDecorator(new UnpinFromStartAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.PinItemToFavorites] = new DebouncedActionDecorator(new PinItemAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.UnpinItemFromFavorites] = new DebouncedActionDecorator(new UnpinItemAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SetAsWallpaperBackground] = new DebouncedActionDecorator(new SetAsWallpaperBackgroundAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SetAsSlideshowBackground] = new DebouncedActionDecorator(new SetAsSlideshowBackgroundAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SetAsLockscreenBackground] = new DebouncedActionDecorator(new SetAsLockscreenBackgroundAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CopyItem] = new DebouncedActionDecorator(new CopyItemAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CopyPath] = new DebouncedActionDecorator(new CopyPathAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CutItem] = new DebouncedActionDecorator(new CutItemAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.PasteItem] = new DebouncedActionDecorator(new PasteItemAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.PasteItemToSelection] = new DebouncedActionDecorator(new PasteItemToSelectionAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.DeleteItem] = new DebouncedActionDecorator(new DeleteItemAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.DeleteItemPermanently] = new DebouncedActionDecorator(new DeleteItemPermanentlyAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.InstallFont] = new DebouncedActionDecorator(new InstallFontAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.InstallInfDriver] = new DebouncedActionDecorator(new InstallInfDriverAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.InstallCertificate] = new DebouncedActionDecorator(new InstallCertificateAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.RunAsAdmin] = new DebouncedActionDecorator(new RunAsAdminAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.RunAsAnotherUser] = new DebouncedActionDecorator(new RunAsAnotherUserAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.RunWithPowershell] = new DebouncedActionDecorator(new RunWithPowershellAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.LaunchPreviewPopup] = new DebouncedActionDecorator(new LaunchPreviewPopupAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CompressIntoArchive] = new DebouncedActionDecorator(new CompressIntoArchiveAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CompressIntoSevenZip] = new DebouncedActionDecorator(new CompressIntoSevenZipAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CompressIntoZip] = new DebouncedActionDecorator(new CompressIntoZipAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.DecompressArchive] = new DebouncedActionDecorator(new DecompressArchive(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.DecompressArchiveHere] = new DebouncedActionDecorator(new DecompressArchiveHere(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.DecompressArchiveToChildFolder] = new DebouncedActionDecorator(new DecompressArchiveToChildFolderAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.RotateLeft] = new DebouncedActionDecorator(new RotateLeftAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.RotateRight] = new DebouncedActionDecorator(new RotateRightAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenItem] = new DebouncedActionDecorator(new OpenItemAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenItemWithApplicationPicker] = new DebouncedActionDecorator(new OpenItemWithApplicationPickerAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenParentFolder] = new DebouncedActionDecorator(new OpenParentFolderAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenInVS] = new DebouncedActionDecorator(new OpenInVSAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenInVSCode] = new DebouncedActionDecorator(new OpenInVSCodeAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenProperties] = new DebouncedActionDecorator(new OpenPropertiesAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenSettings] = new DebouncedActionDecorator(new OpenSettingsAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenTerminal] = new DebouncedActionDecorator(new OpenTerminalAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenTerminalAsAdmin] = new DebouncedActionDecorator(new OpenTerminalAsAdminAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenCommandPalette] = new DebouncedActionDecorator(new OpenCommandPaletteAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.LayoutDecreaseSize] = new DebouncedActionDecorator(new LayoutDecreaseSizeAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.LayoutIncreaseSize] = new DebouncedActionDecorator(new LayoutIncreaseSizeAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.LayoutDetails] = new DebouncedActionDecorator(new LayoutDetailsAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.LayoutTiles] = new DebouncedActionDecorator(new LayoutTilesAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.LayoutGridSmall] = new DebouncedActionDecorator(new LayoutGridSmallAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.LayoutGridMedium] = new DebouncedActionDecorator(new LayoutGridMediumAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.LayoutGridLarge] = new DebouncedActionDecorator(new LayoutGridLargeAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.LayoutColumns] = new DebouncedActionDecorator(new LayoutColumnsAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.LayoutAdaptive] = new DebouncedActionDecorator(new LayoutAdaptiveAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortByName] = new DebouncedActionDecorator(new SortByNameAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortByDateModified] = new DebouncedActionDecorator(new SortByDateModifiedAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortByDateCreated] = new DebouncedActionDecorator(new SortByDateCreatedAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortBySize] = new DebouncedActionDecorator(new SortBySizeAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortByType] = new DebouncedActionDecorator(new SortByTypeAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortBySyncStatus] = new DebouncedActionDecorator(new SortBySyncStatusAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortByTag] = new DebouncedActionDecorator(new SortByTagAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortByPath] = new DebouncedActionDecorator(new SortByPathAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortByOriginalFolder] = new DebouncedActionDecorator(new SortByOriginalFolderAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortByDateDeleted] = new DebouncedActionDecorator(new SortByDateDeletedAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortAscending] = new DebouncedActionDecorator(new SortAscendingAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.SortDescending] = new DebouncedActionDecorator(new SortDescendingAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ToggleSortDirection] = new DebouncedActionDecorator(new ToggleSortDirectionAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ToggleSortDirectoriesAlongsideFiles] = new DebouncedActionDecorator(new ToggleSortDirectoriesAlongsideFilesAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByNone] = new DebouncedActionDecorator(new GroupByNoneAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByName] = new DebouncedActionDecorator(new GroupByNameAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByDateModified] = new DebouncedActionDecorator(new GroupByDateModifiedAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByDateCreated] = new DebouncedActionDecorator(new GroupByDateCreatedAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupBySize] = new DebouncedActionDecorator(new GroupBySizeAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByType] = new DebouncedActionDecorator(new GroupByTypeAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupBySyncStatus] = new DebouncedActionDecorator(new GroupBySyncStatusAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByTag] = new DebouncedActionDecorator(new GroupByTagAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByOriginalFolder] = new DebouncedActionDecorator(new GroupByOriginalFolderAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByDateDeleted] = new DebouncedActionDecorator(new GroupByDateDeletedAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByFolderPath] = new DebouncedActionDecorator(new GroupByFolderPathAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByDateModifiedYear] = new DebouncedActionDecorator(new GroupByDateModifiedYearAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByDateModifiedMonth] = new DebouncedActionDecorator(new GroupByDateModifiedMonthAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByDateCreatedYear] = new DebouncedActionDecorator(new GroupByDateCreatedYearAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByDateCreatedMonth] = new DebouncedActionDecorator(new GroupByDateCreatedMonthAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByDateDeletedYear] = new DebouncedActionDecorator(new GroupByDateDeletedYearAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByDateDeletedMonth] = new DebouncedActionDecorator(new GroupByDateDeletedMonthAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupAscending] = new DebouncedActionDecorator(new GroupAscendingAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupDescending] = new DebouncedActionDecorator(new GroupDescendingAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ToggleGroupDirection] = new DebouncedActionDecorator(new ToggleGroupDirectionAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByYear] = new DebouncedActionDecorator(new GroupByYearAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GroupByMonth] = new DebouncedActionDecorator(new GroupByMonthAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ToggleGroupByDateUnit] = new DebouncedActionDecorator(new ToggleGroupByDateUnitAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.NewTab] = new DebouncedActionDecorator(new NewTabAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.FormatDrive] = new DebouncedActionDecorator(new FormatDriveAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.NavigateBack] = new DebouncedActionDecorator(new NavigateBackAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.NavigateForward] = new DebouncedActionDecorator(new NavigateForwardAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.NavigateUp] = new DebouncedActionDecorator(new NavigateUpAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.DuplicateCurrentTab] = new DebouncedActionDecorator(new DuplicateCurrentTabAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.DuplicateSelectedTab] = new DebouncedActionDecorator(new DuplicateSelectedTabAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CloseTabsToTheLeftCurrent] = new DebouncedActionDecorator(new CloseTabsToTheLeftCurrentAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CloseTabsToTheLeftSelected] = new DebouncedActionDecorator(new CloseTabsToTheLeftSelectedAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CloseTabsToTheRightCurrent] = new DebouncedActionDecorator(new CloseTabsToTheRightCurrentAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CloseTabsToTheRightSelected] = new DebouncedActionDecorator(new CloseTabsToTheRightSelectedAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CloseOtherTabsCurrent] = new DebouncedActionDecorator(new CloseOtherTabsCurrentAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CloseOtherTabsSelected] = new DebouncedActionDecorator(new CloseOtherTabsSelectedAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenDirectoryInNewPane] = new DebouncedActionDecorator(new OpenDirectoryInNewPaneAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenDirectoryInNewTab] = new DebouncedActionDecorator(new OpenDirectoryInNewTabAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenInNewWindowItem] = new DebouncedActionDecorator(new OpenInNewWindowItemAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ReopenClosedTab] = new DebouncedActionDecorator(new ReopenClosedTabAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.PreviousTab] = new DebouncedActionDecorator(new PreviousTabAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.NextTab] = new DebouncedActionDecorator(new NextTabAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.CloseSelectedTab] = new DebouncedActionDecorator(new CloseSelectedTabAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenNewPane] = new DebouncedActionDecorator(new OpenNewPaneAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.ClosePane] = new DebouncedActionDecorator(new ClosePaneAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenFileLocation] = new DebouncedActionDecorator(new OpenFileLocationAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.PlayAll] = new DebouncedActionDecorator(new PlayAllAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GitFetch] = new DebouncedActionDecorator(new GitFetchAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GitInit] = new DebouncedActionDecorator(new GitInitAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GitPull] = new DebouncedActionDecorator(new GitPullAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GitPush] = new DebouncedActionDecorator(new GitPushAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.GitSync] = new DebouncedActionDecorator(new GitSyncAction(), TimeSpan.FromMilliseconds(800)), + [CommandCodes.OpenAllTaggedItems] = new DebouncedActionDecorator(new OpenAllTaggedActions(), TimeSpan.FromMilliseconds(800)) }; private void UpdateHotKeys() From 8139d77cf6b59d4406fd4ebe86f336a31292e50b Mon Sep 17 00:00:00 2001 From: Jerrod Estell Date: Sat, 14 Oct 2023 10:23:03 -0700 Subject: [PATCH 4/5] clean up format, default time of 800ms implemented --- src/Files.App/Actions/DebounceAction.cs | 20 +- .../Actions/DebouncedActionDecorator.cs | 27 +- .../Data/Commands/Manager/CommandManager.cs | 286 +++++++++--------- 3 files changed, 168 insertions(+), 165 deletions(-) diff --git a/src/Files.App/Actions/DebounceAction.cs b/src/Files.App/Actions/DebounceAction.cs index abb7e56b002f..66ffcfdb2ee8 100644 --- a/src/Files.App/Actions/DebounceAction.cs +++ b/src/Files.App/Actions/DebounceAction.cs @@ -9,7 +9,16 @@ namespace Files.App.Actions public abstract class DebouncedAction : IAction { private DateTime lastExecuted = DateTime.MinValue; + private readonly TimeSpan debounceTime; + public abstract string Label { get; } + public abstract string Description { get; } + public abstract RichGlyph Glyph { get; } + public abstract HotKey HotKey { get; } + public abstract HotKey SecondHotKey { get; } + public abstract HotKey ThirdHotKey { get; } + public abstract HotKey MediaHotKey { get; } + public abstract bool IsExecutable { get; } protected DebouncedAction(TimeSpan debounceDuration) { @@ -21,20 +30,11 @@ public virtual bool CanExecuteNow() return DateTime.Now - lastExecuted > debounceTime; } - public virtual void MarkAsExecuted() + public virtual void MarkLastExecutionTime() { lastExecuted = DateTime.Now; } - public abstract string Label { get; } - public abstract string Description { get; } - public abstract RichGlyph Glyph { get; } - public abstract HotKey HotKey { get; } - public abstract HotKey SecondHotKey { get; } - public abstract HotKey ThirdHotKey { get; } - public abstract HotKey MediaHotKey { get; } - public abstract bool IsExecutable { get; } - public abstract Task ExecuteAsync(); } } \ No newline at end of file diff --git a/src/Files.App/Actions/DebouncedActionDecorator.cs b/src/Files.App/Actions/DebouncedActionDecorator.cs index 2e5fa6ac7dea..b263974ffa98 100644 --- a/src/Files.App/Actions/DebouncedActionDecorator.cs +++ b/src/Files.App/Actions/DebouncedActionDecorator.cs @@ -8,14 +8,6 @@ namespace Files.App.Actions { public class DebouncedActionDecorator : DebouncedAction { - private readonly IAction _innerAction; - - public DebouncedActionDecorator(IAction innerAction, TimeSpan debounceDuration) - : base(debounceDuration) - { - _innerAction = innerAction; - } - public override string Label => _innerAction.Label; public override string Description => _innerAction.Description; public override RichGlyph Glyph => _innerAction.Glyph; @@ -25,14 +17,25 @@ public DebouncedActionDecorator(IAction innerAction, TimeSpan debounceDuration) public override HotKey MediaHotKey => _innerAction.MediaHotKey; public override bool IsExecutable => _innerAction.IsExecutable; + private readonly IAction _innerAction; + + /// + /// Initializes a new instance of the DebouncedActionDecorator class. + /// + /// The IAction instance to be wrapped. + /// The debounce duration. Default is 800 milliseconds. + public DebouncedActionDecorator(IAction innerAction, TimeSpan? debounceDuration = null) + : base(debounceDuration ?? TimeSpan.FromMilliseconds(800)) + { + _innerAction = innerAction; + } + public override async Task ExecuteAsync() { if (!CanExecuteNow()) - { return; - } - - MarkAsExecuted(); + + MarkLastExecutionTime(); await _innerAction.ExecuteAsync(); } diff --git a/src/Files.App/Data/Commands/Manager/CommandManager.cs b/src/Files.App/Data/Commands/Manager/CommandManager.cs index 67e3dee05bda..e300078f8f9f 100644 --- a/src/Files.App/Data/Commands/Manager/CommandManager.cs +++ b/src/Files.App/Data/Commands/Manager/CommandManager.cs @@ -199,149 +199,149 @@ public CommandManager() private static IDictionary CreateActions() => new Dictionary { - [CommandCodes.OpenHelp] = new DebouncedActionDecorator(new OpenHelpAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ToggleFullScreen] = new DebouncedActionDecorator(new ToggleFullScreenAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.EnterCompactOverlay] = new DebouncedActionDecorator(new EnterCompactOverlayAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ExitCompactOverlay] = new DebouncedActionDecorator(new ExitCompactOverlayAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ToggleCompactOverlay] = new DebouncedActionDecorator(new ToggleCompactOverlayAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.Search] = new DebouncedActionDecorator(new SearchAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SearchUnindexedItems] = new DebouncedActionDecorator(new SearchUnindexedItemsAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.EditPath] = new DebouncedActionDecorator(new EditPathAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.Redo] = new DebouncedActionDecorator(new RedoAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.Undo] = new DebouncedActionDecorator(new UndoAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ToggleShowHiddenItems] = new DebouncedActionDecorator(new ToggleShowHiddenItemsAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ToggleShowFileExtensions] = new DebouncedActionDecorator(new ToggleShowFileExtensionsAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.TogglePreviewPane] = new DebouncedActionDecorator(new TogglePreviewPaneAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SelectAll] = new DebouncedActionDecorator(new SelectAllAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.InvertSelection] = new DebouncedActionDecorator(new InvertSelectionAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ClearSelection] = new DebouncedActionDecorator(new ClearSelectionAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ToggleSelect] = new DebouncedActionDecorator(new ToggleSelectAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ShareItem] = new DebouncedActionDecorator(new ShareItemAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.EmptyRecycleBin] = new DebouncedActionDecorator(new EmptyRecycleBinAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.RestoreRecycleBin] = new DebouncedActionDecorator(new RestoreRecycleBinAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.RestoreAllRecycleBin] = new DebouncedActionDecorator(new RestoreAllRecycleBinAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.RefreshItems] = new DebouncedActionDecorator(new RefreshItemsAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.Rename] = new DebouncedActionDecorator(new RenameAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CreateShortcut] = new DebouncedActionDecorator(new CreateShortcutAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CreateShortcutFromDialog] = new DebouncedActionDecorator(new CreateShortcutFromDialogAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CreateFolder] = new DebouncedActionDecorator(new CreateFolderAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CreateFolderWithSelection] = new DebouncedActionDecorator(new CreateFolderWithSelectionAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.AddItem] = new DebouncedActionDecorator(new AddItemAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.PinToStart] = new DebouncedActionDecorator(new PinToStartAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.UnpinFromStart] = new DebouncedActionDecorator(new UnpinFromStartAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.PinItemToFavorites] = new DebouncedActionDecorator(new PinItemAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.UnpinItemFromFavorites] = new DebouncedActionDecorator(new UnpinItemAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SetAsWallpaperBackground] = new DebouncedActionDecorator(new SetAsWallpaperBackgroundAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SetAsSlideshowBackground] = new DebouncedActionDecorator(new SetAsSlideshowBackgroundAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SetAsLockscreenBackground] = new DebouncedActionDecorator(new SetAsLockscreenBackgroundAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CopyItem] = new DebouncedActionDecorator(new CopyItemAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CopyPath] = new DebouncedActionDecorator(new CopyPathAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CutItem] = new DebouncedActionDecorator(new CutItemAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.PasteItem] = new DebouncedActionDecorator(new PasteItemAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.PasteItemToSelection] = new DebouncedActionDecorator(new PasteItemToSelectionAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.DeleteItem] = new DebouncedActionDecorator(new DeleteItemAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.DeleteItemPermanently] = new DebouncedActionDecorator(new DeleteItemPermanentlyAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.InstallFont] = new DebouncedActionDecorator(new InstallFontAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.InstallInfDriver] = new DebouncedActionDecorator(new InstallInfDriverAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.InstallCertificate] = new DebouncedActionDecorator(new InstallCertificateAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.RunAsAdmin] = new DebouncedActionDecorator(new RunAsAdminAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.RunAsAnotherUser] = new DebouncedActionDecorator(new RunAsAnotherUserAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.RunWithPowershell] = new DebouncedActionDecorator(new RunWithPowershellAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.LaunchPreviewPopup] = new DebouncedActionDecorator(new LaunchPreviewPopupAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CompressIntoArchive] = new DebouncedActionDecorator(new CompressIntoArchiveAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CompressIntoSevenZip] = new DebouncedActionDecorator(new CompressIntoSevenZipAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CompressIntoZip] = new DebouncedActionDecorator(new CompressIntoZipAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.DecompressArchive] = new DebouncedActionDecorator(new DecompressArchive(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.DecompressArchiveHere] = new DebouncedActionDecorator(new DecompressArchiveHere(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.DecompressArchiveToChildFolder] = new DebouncedActionDecorator(new DecompressArchiveToChildFolderAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.RotateLeft] = new DebouncedActionDecorator(new RotateLeftAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.RotateRight] = new DebouncedActionDecorator(new RotateRightAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenItem] = new DebouncedActionDecorator(new OpenItemAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenItemWithApplicationPicker] = new DebouncedActionDecorator(new OpenItemWithApplicationPickerAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenParentFolder] = new DebouncedActionDecorator(new OpenParentFolderAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenInVS] = new DebouncedActionDecorator(new OpenInVSAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenInVSCode] = new DebouncedActionDecorator(new OpenInVSCodeAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenProperties] = new DebouncedActionDecorator(new OpenPropertiesAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenSettings] = new DebouncedActionDecorator(new OpenSettingsAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenTerminal] = new DebouncedActionDecorator(new OpenTerminalAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenTerminalAsAdmin] = new DebouncedActionDecorator(new OpenTerminalAsAdminAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenCommandPalette] = new DebouncedActionDecorator(new OpenCommandPaletteAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.LayoutDecreaseSize] = new DebouncedActionDecorator(new LayoutDecreaseSizeAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.LayoutIncreaseSize] = new DebouncedActionDecorator(new LayoutIncreaseSizeAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.LayoutDetails] = new DebouncedActionDecorator(new LayoutDetailsAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.LayoutTiles] = new DebouncedActionDecorator(new LayoutTilesAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.LayoutGridSmall] = new DebouncedActionDecorator(new LayoutGridSmallAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.LayoutGridMedium] = new DebouncedActionDecorator(new LayoutGridMediumAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.LayoutGridLarge] = new DebouncedActionDecorator(new LayoutGridLargeAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.LayoutColumns] = new DebouncedActionDecorator(new LayoutColumnsAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.LayoutAdaptive] = new DebouncedActionDecorator(new LayoutAdaptiveAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortByName] = new DebouncedActionDecorator(new SortByNameAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortByDateModified] = new DebouncedActionDecorator(new SortByDateModifiedAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortByDateCreated] = new DebouncedActionDecorator(new SortByDateCreatedAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortBySize] = new DebouncedActionDecorator(new SortBySizeAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortByType] = new DebouncedActionDecorator(new SortByTypeAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortBySyncStatus] = new DebouncedActionDecorator(new SortBySyncStatusAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortByTag] = new DebouncedActionDecorator(new SortByTagAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortByPath] = new DebouncedActionDecorator(new SortByPathAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortByOriginalFolder] = new DebouncedActionDecorator(new SortByOriginalFolderAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortByDateDeleted] = new DebouncedActionDecorator(new SortByDateDeletedAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortAscending] = new DebouncedActionDecorator(new SortAscendingAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.SortDescending] = new DebouncedActionDecorator(new SortDescendingAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ToggleSortDirection] = new DebouncedActionDecorator(new ToggleSortDirectionAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ToggleSortDirectoriesAlongsideFiles] = new DebouncedActionDecorator(new ToggleSortDirectoriesAlongsideFilesAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByNone] = new DebouncedActionDecorator(new GroupByNoneAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByName] = new DebouncedActionDecorator(new GroupByNameAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByDateModified] = new DebouncedActionDecorator(new GroupByDateModifiedAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByDateCreated] = new DebouncedActionDecorator(new GroupByDateCreatedAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupBySize] = new DebouncedActionDecorator(new GroupBySizeAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByType] = new DebouncedActionDecorator(new GroupByTypeAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupBySyncStatus] = new DebouncedActionDecorator(new GroupBySyncStatusAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByTag] = new DebouncedActionDecorator(new GroupByTagAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByOriginalFolder] = new DebouncedActionDecorator(new GroupByOriginalFolderAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByDateDeleted] = new DebouncedActionDecorator(new GroupByDateDeletedAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByFolderPath] = new DebouncedActionDecorator(new GroupByFolderPathAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByDateModifiedYear] = new DebouncedActionDecorator(new GroupByDateModifiedYearAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByDateModifiedMonth] = new DebouncedActionDecorator(new GroupByDateModifiedMonthAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByDateCreatedYear] = new DebouncedActionDecorator(new GroupByDateCreatedYearAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByDateCreatedMonth] = new DebouncedActionDecorator(new GroupByDateCreatedMonthAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByDateDeletedYear] = new DebouncedActionDecorator(new GroupByDateDeletedYearAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByDateDeletedMonth] = new DebouncedActionDecorator(new GroupByDateDeletedMonthAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupAscending] = new DebouncedActionDecorator(new GroupAscendingAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupDescending] = new DebouncedActionDecorator(new GroupDescendingAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ToggleGroupDirection] = new DebouncedActionDecorator(new ToggleGroupDirectionAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByYear] = new DebouncedActionDecorator(new GroupByYearAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GroupByMonth] = new DebouncedActionDecorator(new GroupByMonthAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ToggleGroupByDateUnit] = new DebouncedActionDecorator(new ToggleGroupByDateUnitAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.NewTab] = new DebouncedActionDecorator(new NewTabAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.FormatDrive] = new DebouncedActionDecorator(new FormatDriveAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.NavigateBack] = new DebouncedActionDecorator(new NavigateBackAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.NavigateForward] = new DebouncedActionDecorator(new NavigateForwardAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.NavigateUp] = new DebouncedActionDecorator(new NavigateUpAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.DuplicateCurrentTab] = new DebouncedActionDecorator(new DuplicateCurrentTabAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.DuplicateSelectedTab] = new DebouncedActionDecorator(new DuplicateSelectedTabAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CloseTabsToTheLeftCurrent] = new DebouncedActionDecorator(new CloseTabsToTheLeftCurrentAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CloseTabsToTheLeftSelected] = new DebouncedActionDecorator(new CloseTabsToTheLeftSelectedAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CloseTabsToTheRightCurrent] = new DebouncedActionDecorator(new CloseTabsToTheRightCurrentAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CloseTabsToTheRightSelected] = new DebouncedActionDecorator(new CloseTabsToTheRightSelectedAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CloseOtherTabsCurrent] = new DebouncedActionDecorator(new CloseOtherTabsCurrentAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CloseOtherTabsSelected] = new DebouncedActionDecorator(new CloseOtherTabsSelectedAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenDirectoryInNewPane] = new DebouncedActionDecorator(new OpenDirectoryInNewPaneAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenDirectoryInNewTab] = new DebouncedActionDecorator(new OpenDirectoryInNewTabAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenInNewWindowItem] = new DebouncedActionDecorator(new OpenInNewWindowItemAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ReopenClosedTab] = new DebouncedActionDecorator(new ReopenClosedTabAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.PreviousTab] = new DebouncedActionDecorator(new PreviousTabAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.NextTab] = new DebouncedActionDecorator(new NextTabAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.CloseSelectedTab] = new DebouncedActionDecorator(new CloseSelectedTabAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenNewPane] = new DebouncedActionDecorator(new OpenNewPaneAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.ClosePane] = new DebouncedActionDecorator(new ClosePaneAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenFileLocation] = new DebouncedActionDecorator(new OpenFileLocationAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.PlayAll] = new DebouncedActionDecorator(new PlayAllAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GitFetch] = new DebouncedActionDecorator(new GitFetchAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GitInit] = new DebouncedActionDecorator(new GitInitAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GitPull] = new DebouncedActionDecorator(new GitPullAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GitPush] = new DebouncedActionDecorator(new GitPushAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.GitSync] = new DebouncedActionDecorator(new GitSyncAction(), TimeSpan.FromMilliseconds(800)), - [CommandCodes.OpenAllTaggedItems] = new DebouncedActionDecorator(new OpenAllTaggedActions(), TimeSpan.FromMilliseconds(800)) + [CommandCodes.OpenHelp] = new DebouncedActionDecorator(new OpenHelpAction()), + [CommandCodes.ToggleFullScreen] = new DebouncedActionDecorator(new ToggleFullScreenAction()), + [CommandCodes.EnterCompactOverlay] = new DebouncedActionDecorator(new EnterCompactOverlayAction()), + [CommandCodes.ExitCompactOverlay] = new DebouncedActionDecorator(new ExitCompactOverlayAction()), + [CommandCodes.ToggleCompactOverlay] = new DebouncedActionDecorator(new ToggleCompactOverlayAction()), + [CommandCodes.Search] = new DebouncedActionDecorator(new SearchAction()), + [CommandCodes.SearchUnindexedItems] = new DebouncedActionDecorator(new SearchUnindexedItemsAction()), + [CommandCodes.EditPath] = new DebouncedActionDecorator(new EditPathAction()), + [CommandCodes.Redo] = new DebouncedActionDecorator(new RedoAction()), + [CommandCodes.Undo] = new DebouncedActionDecorator(new UndoAction()), + [CommandCodes.ToggleShowHiddenItems] = new DebouncedActionDecorator(new ToggleShowHiddenItemsAction()), + [CommandCodes.ToggleShowFileExtensions] = new DebouncedActionDecorator(new ToggleShowFileExtensionsAction()), + [CommandCodes.TogglePreviewPane] = new DebouncedActionDecorator(new TogglePreviewPaneAction()), + [CommandCodes.SelectAll] = new DebouncedActionDecorator(new SelectAllAction()), + [CommandCodes.InvertSelection] = new DebouncedActionDecorator(new InvertSelectionAction()), + [CommandCodes.ClearSelection] = new DebouncedActionDecorator(new ClearSelectionAction()), + [CommandCodes.ToggleSelect] = new DebouncedActionDecorator(new ToggleSelectAction()), + [CommandCodes.ShareItem] = new DebouncedActionDecorator(new ShareItemAction()), + [CommandCodes.EmptyRecycleBin] = new DebouncedActionDecorator(new EmptyRecycleBinAction()), + [CommandCodes.RestoreRecycleBin] = new DebouncedActionDecorator(new RestoreRecycleBinAction()), + [CommandCodes.RestoreAllRecycleBin] = new DebouncedActionDecorator(new RestoreAllRecycleBinAction()), + [CommandCodes.RefreshItems] = new DebouncedActionDecorator(new RefreshItemsAction()), + [CommandCodes.Rename] = new DebouncedActionDecorator(new RenameAction()), + [CommandCodes.CreateShortcut] = new DebouncedActionDecorator(new CreateShortcutAction()), + [CommandCodes.CreateShortcutFromDialog] = new DebouncedActionDecorator(new CreateShortcutFromDialogAction()), + [CommandCodes.CreateFolder] = new DebouncedActionDecorator(new CreateFolderAction()), + [CommandCodes.CreateFolderWithSelection] = new DebouncedActionDecorator(new CreateFolderWithSelectionAction()), + [CommandCodes.AddItem] = new DebouncedActionDecorator(new AddItemAction()), + [CommandCodes.PinToStart] = new DebouncedActionDecorator(new PinToStartAction()), + [CommandCodes.UnpinFromStart] = new DebouncedActionDecorator(new UnpinFromStartAction()), + [CommandCodes.PinItemToFavorites] = new DebouncedActionDecorator(new PinItemAction()), + [CommandCodes.UnpinItemFromFavorites] = new DebouncedActionDecorator(new UnpinItemAction()), + [CommandCodes.SetAsWallpaperBackground] = new DebouncedActionDecorator(new SetAsWallpaperBackgroundAction()), + [CommandCodes.SetAsSlideshowBackground] = new DebouncedActionDecorator(new SetAsSlideshowBackgroundAction()), + [CommandCodes.SetAsLockscreenBackground] = new DebouncedActionDecorator(new SetAsLockscreenBackgroundAction()), + [CommandCodes.CopyItem] = new DebouncedActionDecorator(new CopyItemAction()), + [CommandCodes.CopyPath] = new DebouncedActionDecorator(new CopyPathAction()), + [CommandCodes.CutItem] = new DebouncedActionDecorator(new CutItemAction()), + [CommandCodes.PasteItem] = new DebouncedActionDecorator(new PasteItemAction()), + [CommandCodes.PasteItemToSelection] = new DebouncedActionDecorator(new PasteItemToSelectionAction()), + [CommandCodes.DeleteItem] = new DebouncedActionDecorator(new DeleteItemAction()), + [CommandCodes.DeleteItemPermanently] = new DebouncedActionDecorator(new DeleteItemPermanentlyAction()), + [CommandCodes.InstallFont] = new DebouncedActionDecorator(new InstallFontAction()), + [CommandCodes.InstallInfDriver] = new DebouncedActionDecorator(new InstallInfDriverAction()), + [CommandCodes.InstallCertificate] = new DebouncedActionDecorator(new InstallCertificateAction()), + [CommandCodes.RunAsAdmin] = new DebouncedActionDecorator(new RunAsAdminAction()), + [CommandCodes.RunAsAnotherUser] = new DebouncedActionDecorator(new RunAsAnotherUserAction()), + [CommandCodes.RunWithPowershell] = new DebouncedActionDecorator(new RunWithPowershellAction()), + [CommandCodes.LaunchPreviewPopup] = new DebouncedActionDecorator(new LaunchPreviewPopupAction()), + [CommandCodes.CompressIntoArchive] = new DebouncedActionDecorator(new CompressIntoArchiveAction()), + [CommandCodes.CompressIntoSevenZip] = new DebouncedActionDecorator(new CompressIntoSevenZipAction()), + [CommandCodes.CompressIntoZip] = new DebouncedActionDecorator(new CompressIntoZipAction()), + [CommandCodes.DecompressArchive] = new DebouncedActionDecorator(new DecompressArchive()), + [CommandCodes.DecompressArchiveHere] = new DebouncedActionDecorator(new DecompressArchiveHere()), + [CommandCodes.DecompressArchiveToChildFolder] = new DebouncedActionDecorator(new DecompressArchiveToChildFolderAction()), + [CommandCodes.RotateLeft] = new DebouncedActionDecorator(new RotateLeftAction()), + [CommandCodes.RotateRight] = new DebouncedActionDecorator(new RotateRightAction()), + [CommandCodes.OpenItem] = new DebouncedActionDecorator(new OpenItemAction()), + [CommandCodes.OpenItemWithApplicationPicker] = new DebouncedActionDecorator(new OpenItemWithApplicationPickerAction()), + [CommandCodes.OpenParentFolder] = new DebouncedActionDecorator(new OpenParentFolderAction()), + [CommandCodes.OpenInVS] = new DebouncedActionDecorator(new OpenInVSAction()), + [CommandCodes.OpenInVSCode] = new DebouncedActionDecorator(new OpenInVSCodeAction()), + [CommandCodes.OpenProperties] = new DebouncedActionDecorator(new OpenPropertiesAction()), + [CommandCodes.OpenSettings] = new DebouncedActionDecorator(new OpenSettingsAction()), + [CommandCodes.OpenTerminal] = new DebouncedActionDecorator(new OpenTerminalAction()), + [CommandCodes.OpenTerminalAsAdmin] = new DebouncedActionDecorator(new OpenTerminalAsAdminAction()), + [CommandCodes.OpenCommandPalette] = new DebouncedActionDecorator(new OpenCommandPaletteAction()), + [CommandCodes.LayoutDecreaseSize] = new DebouncedActionDecorator(new LayoutDecreaseSizeAction()), + [CommandCodes.LayoutIncreaseSize] = new DebouncedActionDecorator(new LayoutIncreaseSizeAction()), + [CommandCodes.LayoutDetails] = new DebouncedActionDecorator(new LayoutDetailsAction()), + [CommandCodes.LayoutTiles] = new DebouncedActionDecorator(new LayoutTilesAction()), + [CommandCodes.LayoutGridSmall] = new DebouncedActionDecorator(new LayoutGridSmallAction()), + [CommandCodes.LayoutGridMedium] = new DebouncedActionDecorator(new LayoutGridMediumAction()), + [CommandCodes.LayoutGridLarge] = new DebouncedActionDecorator(new LayoutGridLargeAction()), + [CommandCodes.LayoutColumns] = new DebouncedActionDecorator(new LayoutColumnsAction()), + [CommandCodes.LayoutAdaptive] = new DebouncedActionDecorator(new LayoutAdaptiveAction()), + [CommandCodes.SortByName] = new DebouncedActionDecorator(new SortByNameAction()), + [CommandCodes.SortByDateModified] = new DebouncedActionDecorator(new SortByDateModifiedAction()), + [CommandCodes.SortByDateCreated] = new DebouncedActionDecorator(new SortByDateCreatedAction()), + [CommandCodes.SortBySize] = new DebouncedActionDecorator(new SortBySizeAction()), + [CommandCodes.SortByType] = new DebouncedActionDecorator(new SortByTypeAction()), + [CommandCodes.SortBySyncStatus] = new DebouncedActionDecorator(new SortBySyncStatusAction()), + [CommandCodes.SortByTag] = new DebouncedActionDecorator(new SortByTagAction()), + [CommandCodes.SortByPath] = new DebouncedActionDecorator(new SortByPathAction()), + [CommandCodes.SortByOriginalFolder] = new DebouncedActionDecorator(new SortByOriginalFolderAction()), + [CommandCodes.SortByDateDeleted] = new DebouncedActionDecorator(new SortByDateDeletedAction()), + [CommandCodes.SortAscending] = new DebouncedActionDecorator(new SortAscendingAction()), + [CommandCodes.SortDescending] = new DebouncedActionDecorator(new SortDescendingAction()), + [CommandCodes.ToggleSortDirection] = new DebouncedActionDecorator(new ToggleSortDirectionAction()), + [CommandCodes.ToggleSortDirectoriesAlongsideFiles] = new DebouncedActionDecorator(new ToggleSortDirectoriesAlongsideFilesAction()), + [CommandCodes.GroupByNone] = new DebouncedActionDecorator(new GroupByNoneAction()), + [CommandCodes.GroupByName] = new DebouncedActionDecorator(new GroupByNameAction()), + [CommandCodes.GroupByDateModified] = new DebouncedActionDecorator(new GroupByDateModifiedAction()), + [CommandCodes.GroupByDateCreated] = new DebouncedActionDecorator(new GroupByDateCreatedAction()), + [CommandCodes.GroupBySize] = new DebouncedActionDecorator(new GroupBySizeAction()), + [CommandCodes.GroupByType] = new DebouncedActionDecorator(new GroupByTypeAction()), + [CommandCodes.GroupBySyncStatus] = new DebouncedActionDecorator(new GroupBySyncStatusAction()), + [CommandCodes.GroupByTag] = new DebouncedActionDecorator(new GroupByTagAction()), + [CommandCodes.GroupByOriginalFolder] = new DebouncedActionDecorator(new GroupByOriginalFolderAction()), + [CommandCodes.GroupByDateDeleted] = new DebouncedActionDecorator(new GroupByDateDeletedAction()), + [CommandCodes.GroupByFolderPath] = new DebouncedActionDecorator(new GroupByFolderPathAction()), + [CommandCodes.GroupByDateModifiedYear] = new DebouncedActionDecorator(new GroupByDateModifiedYearAction()), + [CommandCodes.GroupByDateModifiedMonth] = new DebouncedActionDecorator(new GroupByDateModifiedMonthAction()), + [CommandCodes.GroupByDateCreatedYear] = new DebouncedActionDecorator(new GroupByDateCreatedYearAction()), + [CommandCodes.GroupByDateCreatedMonth] = new DebouncedActionDecorator(new GroupByDateCreatedMonthAction()), + [CommandCodes.GroupByDateDeletedYear] = new DebouncedActionDecorator(new GroupByDateDeletedYearAction()), + [CommandCodes.GroupByDateDeletedMonth] = new DebouncedActionDecorator(new GroupByDateDeletedMonthAction()), + [CommandCodes.GroupAscending] = new DebouncedActionDecorator(new GroupAscendingAction()), + [CommandCodes.GroupDescending] = new DebouncedActionDecorator(new GroupDescendingAction()), + [CommandCodes.ToggleGroupDirection] = new DebouncedActionDecorator(new ToggleGroupDirectionAction()), + [CommandCodes.GroupByYear] = new DebouncedActionDecorator(new GroupByYearAction()), + [CommandCodes.GroupByMonth] = new DebouncedActionDecorator(new GroupByMonthAction()), + [CommandCodes.ToggleGroupByDateUnit] = new DebouncedActionDecorator(new ToggleGroupByDateUnitAction()), + [CommandCodes.NewTab] = new DebouncedActionDecorator(new NewTabAction()), + [CommandCodes.FormatDrive] = new DebouncedActionDecorator(new FormatDriveAction()), + [CommandCodes.NavigateBack] = new DebouncedActionDecorator(new NavigateBackAction()), + [CommandCodes.NavigateForward] = new DebouncedActionDecorator(new NavigateForwardAction()), + [CommandCodes.NavigateUp] = new DebouncedActionDecorator(new NavigateUpAction()), + [CommandCodes.DuplicateCurrentTab] = new DebouncedActionDecorator(new DuplicateCurrentTabAction()), + [CommandCodes.DuplicateSelectedTab] = new DebouncedActionDecorator(new DuplicateSelectedTabAction()), + [CommandCodes.CloseTabsToTheLeftCurrent] = new DebouncedActionDecorator(new CloseTabsToTheLeftCurrentAction()), + [CommandCodes.CloseTabsToTheLeftSelected] = new DebouncedActionDecorator(new CloseTabsToTheLeftSelectedAction()), + [CommandCodes.CloseTabsToTheRightCurrent] = new DebouncedActionDecorator(new CloseTabsToTheRightCurrentAction()), + [CommandCodes.CloseTabsToTheRightSelected] = new DebouncedActionDecorator(new CloseTabsToTheRightSelectedAction()), + [CommandCodes.CloseOtherTabsCurrent] = new DebouncedActionDecorator(new CloseOtherTabsCurrentAction()), + [CommandCodes.CloseOtherTabsSelected] = new DebouncedActionDecorator(new CloseOtherTabsSelectedAction()), + [CommandCodes.OpenDirectoryInNewPane] = new DebouncedActionDecorator(new OpenDirectoryInNewPaneAction()), + [CommandCodes.OpenDirectoryInNewTab] = new DebouncedActionDecorator(new OpenDirectoryInNewTabAction()), + [CommandCodes.OpenInNewWindowItem] = new DebouncedActionDecorator(new OpenInNewWindowItemAction()), + [CommandCodes.ReopenClosedTab] = new DebouncedActionDecorator(new ReopenClosedTabAction()), + [CommandCodes.PreviousTab] = new DebouncedActionDecorator(new PreviousTabAction()), + [CommandCodes.NextTab] = new DebouncedActionDecorator(new NextTabAction()), + [CommandCodes.CloseSelectedTab] = new DebouncedActionDecorator(new CloseSelectedTabAction()), + [CommandCodes.OpenNewPane] = new DebouncedActionDecorator(new OpenNewPaneAction()), + [CommandCodes.ClosePane] = new DebouncedActionDecorator(new ClosePaneAction()), + [CommandCodes.OpenFileLocation] = new DebouncedActionDecorator(new OpenFileLocationAction()), + [CommandCodes.PlayAll] = new DebouncedActionDecorator(new PlayAllAction()), + [CommandCodes.GitFetch] = new DebouncedActionDecorator(new GitFetchAction()), + [CommandCodes.GitInit] = new DebouncedActionDecorator(new GitInitAction()), + [CommandCodes.GitPull] = new DebouncedActionDecorator(new GitPullAction()), + [CommandCodes.GitPush] = new DebouncedActionDecorator(new GitPushAction()), + [CommandCodes.GitSync] = new DebouncedActionDecorator(new GitSyncAction()), + [CommandCodes.OpenAllTaggedItems] = new DebouncedActionDecorator(new OpenAllTaggedActions(), TimeSpan.FromMilliseconds(1000)) }; private void UpdateHotKeys() From ef7073815e50f5a38cf8fc3104e0f153ba4e80f0 Mon Sep 17 00:00:00 2001 From: Jerrod Estell Date: Mon, 16 Oct 2023 20:56:54 -0700 Subject: [PATCH 5/5] Prepare to merge --- src/Files.App/Actions/DebounceAction.cs | 10 +++++----- src/Files.App/Data/Commands/Manager/CommandManager.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Files.App/Actions/DebounceAction.cs b/src/Files.App/Actions/DebounceAction.cs index 66ffcfdb2ee8..85a2f58b5179 100644 --- a/src/Files.App/Actions/DebounceAction.cs +++ b/src/Files.App/Actions/DebounceAction.cs @@ -8,9 +8,9 @@ namespace Files.App.Actions { public abstract class DebouncedAction : IAction { - private DateTime lastExecuted = DateTime.MinValue; + private DateTime lastExecutedTime = DateTime.MinValue; - private readonly TimeSpan debounceTime; + private readonly TimeSpan debounceTimeSpan; public abstract string Label { get; } public abstract string Description { get; } public abstract RichGlyph Glyph { get; } @@ -22,17 +22,17 @@ public abstract class DebouncedAction : IAction protected DebouncedAction(TimeSpan debounceDuration) { - debounceTime = debounceDuration; + debounceTimeSpan = debounceDuration; } public virtual bool CanExecuteNow() { - return DateTime.Now - lastExecuted > debounceTime; + return DateTime.Now - lastExecutedTime > debounceTimeSpan; } public virtual void MarkLastExecutionTime() { - lastExecuted = DateTime.Now; + lastExecutedTime = DateTime.Now; } public abstract Task ExecuteAsync(); diff --git a/src/Files.App/Data/Commands/Manager/CommandManager.cs b/src/Files.App/Data/Commands/Manager/CommandManager.cs index e300078f8f9f..548e0f79d277 100644 --- a/src/Files.App/Data/Commands/Manager/CommandManager.cs +++ b/src/Files.App/Data/Commands/Manager/CommandManager.cs @@ -341,7 +341,7 @@ public CommandManager() [CommandCodes.GitPull] = new DebouncedActionDecorator(new GitPullAction()), [CommandCodes.GitPush] = new DebouncedActionDecorator(new GitPushAction()), [CommandCodes.GitSync] = new DebouncedActionDecorator(new GitSyncAction()), - [CommandCodes.OpenAllTaggedItems] = new DebouncedActionDecorator(new OpenAllTaggedActions(), TimeSpan.FromMilliseconds(1000)) + [CommandCodes.OpenAllTaggedItems] = new DebouncedActionDecorator(new OpenAllTaggedActions()) }; private void UpdateHotKeys()