fix(ui): re-evaluate RunNow CanExecute when worker connection changes
Subscribe to WorkerClient.PropertyChanged in TaskListViewModel and call NotifyCanExecuteChanged on every TaskItemViewModel.RunNowCommand when IsConnected flips, so the button enables immediately on reconnect without waiting for the next task DB refresh. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
981b8e4a3d
commit
473e0f71d5
@@ -44,6 +44,15 @@ public partial class TaskListViewModel : ViewModelBase
|
||||
|
||||
worker.TaskUpdatedEvent += OnTaskUpdated;
|
||||
worker.TaskFinishedEvent += (_, taskId, _, _) => OnTaskUpdated(taskId);
|
||||
worker.PropertyChanged += (_, e) =>
|
||||
{
|
||||
if (e.PropertyName == nameof(WorkerClient.IsConnected))
|
||||
Avalonia.Threading.Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
foreach (var t in Tasks)
|
||||
t.RunNowCommand.NotifyCanExecuteChanged();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public async Task LoadAsync(string? listId)
|
||||
|
||||
Reference in New Issue
Block a user