Skip to content

Commit 6bf5864

Browse files
CopilotJusterZhu
andcommitted
Convert commands to AsyncRelayCommand for proper async/await pattern
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
1 parent 840fb02 commit 6bf5864

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

src/ViewModels/ExtensionViewModel.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public class ExtensionViewModel : ObservableObject
2525
private RelayCommand? _clearCommand;
2626
private AsyncRelayCommand? _selectDependenciesCommand;
2727
private ExtensionDependencySelectionModel? _selectedDependency;
28-
private RelayCommand<CustomPropertyModel>? _removeCustomPropertyCommand;
29-
private RelayCommand? _addCustomPropertyCommand;
28+
private AsyncRelayCommand<CustomPropertyModel>? _removeCustomPropertyCommand;
29+
private AsyncRelayCommand? _addCustomPropertyCommand;
3030
private string? _newCustomPropertyKey;
3131
private string? _newCustomPropertyValue;
3232

@@ -77,14 +77,14 @@ public ExtensionDependencySelectionModel? SelectedDependency
7777
set => SetProperty(ref _selectedDependency, value);
7878
}
7979

80-
public RelayCommand<CustomPropertyModel> RemoveCustomPropertyCommand
80+
public AsyncRelayCommand<CustomPropertyModel> RemoveCustomPropertyCommand
8181
{
82-
get => _removeCustomPropertyCommand ??= new RelayCommand<CustomPropertyModel>(RemoveCustomPropertyAction);
82+
get => _removeCustomPropertyCommand ??= new AsyncRelayCommand<CustomPropertyModel>(RemoveCustomPropertyAction);
8383
}
8484

85-
public RelayCommand AddCustomPropertyCommand
85+
public AsyncRelayCommand AddCustomPropertyCommand
8686
{
87-
get => _addCustomPropertyCommand ??= new RelayCommand(AddCustomPropertyAction, CanAddCustomProperty);
87+
get => _addCustomPropertyCommand ??= new AsyncRelayCommand(AddCustomPropertyAction, CanAddCustomProperty);
8888
}
8989

9090
public string? NewCustomPropertyKey
@@ -311,7 +311,7 @@ private bool CanAddCustomProperty()
311311
!string.IsNullOrWhiteSpace(NewCustomPropertyValue);
312312
}
313313

314-
private async void AddCustomPropertyAction()
314+
private async Task AddCustomPropertyAction()
315315
{
316316
try
317317
{
@@ -357,7 +357,7 @@ private async void AddCustomPropertyAction()
357357
}
358358
}
359359

360-
private async void RemoveCustomPropertyAction(CustomPropertyModel? property)
360+
private async Task RemoveCustomPropertyAction(CustomPropertyModel? property)
361361
{
362362
try
363363
{
@@ -367,12 +367,6 @@ private async void RemoveCustomPropertyAction(CustomPropertyModel? property)
367367
return;
368368
}
369369

370-
if (string.IsNullOrWhiteSpace(property.Key))
371-
{
372-
await MessageBox.ShowAsync("Property key is invalid", "Validation Error", Buttons.OK);
373-
return;
374-
}
375-
376370
// Remove from dictionary
377371
if (ConfigModel.CustomProperties.ContainsKey(property.Key))
378372
{

0 commit comments

Comments
 (0)