refactor(ui): scope "Let Claude handle it" to a single list
This commit is contained in:
@@ -100,18 +100,6 @@ public sealed partial class ListsIslandViewModel : ViewModelBase, IDisposable
|
||||
LetClaudeHandleRequested?.Invoke(new MergeHelperRequest(rawId, ids));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task LetClaudeHandleAllAsync()
|
||||
{
|
||||
if (Dialogs is null || _services is null) return;
|
||||
var vm = _services.GetRequiredService<MergeHelperSelectionModalViewModel>();
|
||||
vm.Configure(null, null);
|
||||
await vm.LoadAsync();
|
||||
var ids = await Dialogs.ShowMergeHelperSelectionAsync(vm);
|
||||
if (ids is { Count: > 0 })
|
||||
LetClaudeHandleRequested?.Invoke(new MergeHelperRequest(null, ids));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void OpenInExplorer(ListNavItemViewModel? row)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@ public sealed partial class MergeHelperTaskRowViewModel : ViewModelBase
|
||||
public required string Id { get; init; }
|
||||
public required string Title { get; init; }
|
||||
public required string StatusText { get; init; }
|
||||
public required string ListName { get; init; }
|
||||
|
||||
[ObservableProperty] private bool _isSelected;
|
||||
}
|
||||
@@ -27,12 +26,11 @@ public sealed partial class MergeHelperTaskRowViewModel : ViewModelBase
|
||||
public sealed partial class MergeHelperSelectionModalViewModel : ViewModelBase
|
||||
{
|
||||
private readonly IDbContextFactory<ClaudeDoDbContext> _dbFactory;
|
||||
private string? _listId;
|
||||
private string _listId = "";
|
||||
|
||||
public ObservableCollection<MergeHelperTaskRowViewModel> Tasks { get; } = new();
|
||||
|
||||
[ObservableProperty] private string _scopeLabel = "";
|
||||
[ObservableProperty] private bool _isGlobal;
|
||||
|
||||
public bool HasTasks => Tasks.Count > 0;
|
||||
public bool CanConfirm => Tasks.Any(t => t.IsSelected);
|
||||
@@ -43,13 +41,10 @@ public sealed partial class MergeHelperSelectionModalViewModel : ViewModelBase
|
||||
public MergeHelperSelectionModalViewModel(IDbContextFactory<ClaudeDoDbContext> dbFactory)
|
||||
=> _dbFactory = dbFactory;
|
||||
|
||||
public void Configure(string? listId, string? listName)
|
||||
public void Configure(string listId, string listName)
|
||||
{
|
||||
_listId = listId;
|
||||
IsGlobal = listId is null;
|
||||
ScopeLabel = listId is null
|
||||
? Loc.T("modals.mergeHelper.scopeAll")
|
||||
: Loc.T("modals.mergeHelper.scopeList", listName ?? "");
|
||||
ScopeLabel = Loc.T("modals.mergeHelper.scopeList", listName);
|
||||
}
|
||||
|
||||
public async Task LoadAsync(CancellationToken ct = default)
|
||||
@@ -58,14 +53,11 @@ public sealed partial class MergeHelperSelectionModalViewModel : ViewModelBase
|
||||
Tasks.Clear();
|
||||
|
||||
await using var ctx = await _dbFactory.CreateDbContextAsync(ct);
|
||||
var query = ctx.Tasks.AsNoTracking()
|
||||
.Where(t => t.Status != TaskStatus.Done && t.Status != TaskStatus.Cancelled);
|
||||
if (_listId is not null)
|
||||
query = query.Where(t => t.ListId == _listId);
|
||||
|
||||
var candidates = await query
|
||||
var candidates = await ctx.Tasks.AsNoTracking()
|
||||
.Where(t => t.Status != TaskStatus.Done && t.Status != TaskStatus.Cancelled)
|
||||
.Where(t => t.ListId == _listId)
|
||||
.OrderBy(t => t.SortOrder).ThenBy(t => t.CreatedAt)
|
||||
.Select(t => new { t.Id, t.Title, t.Status, ListName = t.List.Name })
|
||||
.Select(t => new { t.Id, t.Title, t.Status })
|
||||
.ToListAsync(ct);
|
||||
|
||||
foreach (var c in candidates)
|
||||
@@ -75,7 +67,6 @@ public sealed partial class MergeHelperSelectionModalViewModel : ViewModelBase
|
||||
Id = c.Id,
|
||||
Title = c.Title,
|
||||
StatusText = c.Status.ToString(),
|
||||
ListName = c.ListName,
|
||||
IsSelected = IsTickedByDefault(c.Status),
|
||||
};
|
||||
row.PropertyChanged += OnRowChanged;
|
||||
|
||||
Reference in New Issue
Block a user