fix(ui): capture CurrentListId before await in AddTask

This commit is contained in:
mika kuns
2026-04-17 14:30:35 +02:00
parent 5f3d41e1f6
commit aa1008dcff

View File

@@ -157,17 +157,20 @@ public partial class TaskListViewModel : ViewModelBase
[RelayCommand(CanExecute = nameof(CanAddTask))] [RelayCommand(CanExecute = nameof(CanAddTask))]
private async Task AddTask() private async Task AddTask()
{ {
var listId = CurrentListId;
if (listId is null) return;
string defaultCommitType; string defaultCommitType;
using (var context = _dbFactory.CreateDbContext()) using (var context = _dbFactory.CreateDbContext())
{ {
var listRepo = new ListRepository(context); var listRepo = new ListRepository(context);
var list = await listRepo.GetByIdAsync(CurrentListId); var list = await listRepo.GetByIdAsync(listId);
defaultCommitType = list?.DefaultCommitType ?? "chore"; defaultCommitType = list?.DefaultCommitType ?? "chore";
} }
var editor = _editorFactory(); var editor = _editorFactory();
await editor.LoadAgentsAsync(_worker); await editor.LoadAgentsAsync(_worker);
editor.InitForCreate(CurrentListId, defaultCommitType); editor.InitForCreate(listId, defaultCommitType);
var window = new TaskEditorView { DataContext = editor }; var window = new TaskEditorView { DataContext = editor };
editor.RequestClose += () => window.Close(); editor.RequestClose += () => window.Close();