Skip to content

Commit eb53785

Browse files
authored
The RichCommand implementation no longer uses RelayCommand. (#11778)
1 parent 46818f2 commit eb53785

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Files.App/Commands/Manager/CommandManager.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using CommunityToolkit.Mvvm.ComponentModel;
2-
using CommunityToolkit.Mvvm.Input;
32
using Files.App.Actions;
43
using Files.App.Actions.Content.Archives;
54
using Files.App.Actions.Content.Background;
@@ -16,7 +15,6 @@
1615
using System.Diagnostics;
1716
using System.Linq;
1817
using System.Threading.Tasks;
19-
using System.Windows.Input;
2018

2119
namespace Files.App.Commands
2220
{
@@ -252,7 +250,6 @@ private class ActionCommand : ObservableObject, IRichCommand
252250
public event EventHandler? CanExecuteChanged;
253251

254252
private readonly IAction action;
255-
private readonly ICommand command;
256253

257254
public CommandCodes Code { get; }
258255

@@ -279,7 +276,7 @@ public bool IsOn
279276
set
280277
{
281278
if (action is IToggleAction toggleAction && toggleAction.IsOn != value)
282-
command.Execute(null);
279+
Execute(null);
283280
}
284281
}
285282

@@ -294,7 +291,6 @@ public ActionCommand(CommandCodes code, IAction action)
294291
OpacityStyle = action.Glyph.ToOpacityStyle();
295292
HotKeyText = GetHotKeyText();
296293
LabelWithHotKey = HotKeyText is null ? Label : $"{Label} ({HotKeyText})";
297-
command = new AsyncRelayCommand(ExecuteAsync);
298294

299295
if (action is INotifyPropertyChanging notifyPropertyChanging)
300296
notifyPropertyChanging.PropertyChanging += Action_PropertyChanging;
@@ -303,15 +299,15 @@ public ActionCommand(CommandCodes code, IAction action)
303299
}
304300

305301
public bool CanExecute(object? parameter) => action.IsExecutable;
306-
public void Execute(object? parameter) => command.Execute(parameter);
302+
public async void Execute(object? parameter) => await ExecuteAsync();
307303

308304
public async Task ExecuteAsync()
309305
{
310306
if (IsExecutable)
311307
await action.ExecuteAsync();
312308
}
313309

314-
public async void ExecuteTapped(object sender, TappedRoutedEventArgs e) => await action.ExecuteAsync();
310+
public async void ExecuteTapped(object sender, TappedRoutedEventArgs e) => await ExecuteAsync();
315311

316312
private void Action_PropertyChanging(object? sender, PropertyChangingEventArgs e)
317313
{

0 commit comments

Comments
 (0)