Merge claudedo/64fbe15dae7e4d81b8c1045baa7e3c87
This commit is contained in:
@@ -30,6 +30,9 @@ public sealed partial class ListsIslandViewModel : ViewModelBase, IDisposable
|
||||
public event EventHandler? FocusSearchRequested;
|
||||
public void RequestFocusSearch() => FocusSearchRequested?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
// mirrors TasksIslandViewModel.ErrorReported — surfaces modal-owned failures in the footer strip.
|
||||
public event Action<string>? ErrorReported;
|
||||
|
||||
public IDialogService? Dialogs { get; set; }
|
||||
|
||||
[RelayCommand]
|
||||
@@ -58,6 +61,7 @@ public sealed partial class ListsIslandViewModel : ViewModelBase, IDisposable
|
||||
{
|
||||
if (Dialogs is null || _services is null) return;
|
||||
var vm = _services.GetRequiredService<RepoImportModalViewModel>();
|
||||
vm.ErrorReported += msg => ErrorReported?.Invoke(msg);
|
||||
await vm.LoadAsync();
|
||||
await Dialogs.ShowRepoImportAsync(vm);
|
||||
await LoadAsync();
|
||||
|
||||
@@ -237,6 +237,7 @@ public sealed partial class IslandsShellViewModel : ViewModelBase, IDisposable
|
||||
Tasks.NotesRequested += () => Details.ShowNotes();
|
||||
Tasks.PrepRequested += () => Details.ShowPrep();
|
||||
Tasks.ErrorReported += FlashFooterError;
|
||||
Lists.ErrorReported += FlashFooterError;
|
||||
Tasks.OpenConPtySessionRequested += taskId =>
|
||||
{
|
||||
OpenMissionControl();
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.ComponentModel;
|
||||
using ClaudeDo.Data;
|
||||
using ClaudeDo.Data.Models;
|
||||
using ClaudeDo.Data.Repositories;
|
||||
using ClaudeDo.Ui.Localization;
|
||||
using ClaudeDo.Ui.Services;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@@ -28,12 +29,14 @@ public sealed partial class RepoImportItemViewModel : ViewModelBase
|
||||
public sealed partial class RepoImportModalViewModel : ViewModelBase
|
||||
{
|
||||
private readonly IDbContextFactory<ClaudeDoDbContext> _dbFactory;
|
||||
private readonly IWorkerClient _workerClient;
|
||||
private readonly HashSet<string> _existingDirs = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly List<string> _folders = new();
|
||||
|
||||
public ObservableCollection<RepoImportItemViewModel> Repos { get; } = new();
|
||||
|
||||
public Action? CloseAction { get; set; }
|
||||
public event Action<string>? ErrorReported;
|
||||
|
||||
[ObservableProperty] private string _searchText = "";
|
||||
|
||||
@@ -42,9 +45,10 @@ public sealed partial class RepoImportModalViewModel : ViewModelBase
|
||||
public string CreateButtonText => $"Create {CreateCount} list(s)";
|
||||
public bool HasFolders => _folders.Count > 0;
|
||||
|
||||
public RepoImportModalViewModel(IDbContextFactory<ClaudeDoDbContext> dbFactory)
|
||||
public RepoImportModalViewModel(IDbContextFactory<ClaudeDoDbContext> dbFactory, IWorkerClient workerClient)
|
||||
{
|
||||
_dbFactory = dbFactory;
|
||||
_workerClient = workerClient;
|
||||
}
|
||||
|
||||
public async Task LoadAsync(CancellationToken ct = default)
|
||||
@@ -61,9 +65,15 @@ public sealed partial class RepoImportModalViewModel : ViewModelBase
|
||||
_existingDirs.Add(l.WorkingDir!);
|
||||
}
|
||||
|
||||
var settings = new AppSettingsRepository(ctx);
|
||||
foreach (var f in await settings.GetRepoImportFoldersAsync(ct))
|
||||
AddFolderToSet(f);
|
||||
try
|
||||
{
|
||||
foreach (var f in await _workerClient.GetRepoImportFoldersAsync())
|
||||
AddFolderToSet(f);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorReported?.Invoke(Loc.T("vm.repoImport.loadFailed", ex.Message));
|
||||
}
|
||||
|
||||
ScanAndAdd(_folders);
|
||||
OnPropertyChanged(nameof(HasFolders));
|
||||
@@ -155,8 +165,14 @@ public sealed partial class RepoImportModalViewModel : ViewModelBase
|
||||
|
||||
private async Task SaveFoldersAsync()
|
||||
{
|
||||
await using var ctx = await _dbFactory.CreateDbContextAsync();
|
||||
await new AppSettingsRepository(ctx).SetRepoImportFoldersAsync(_folders);
|
||||
try
|
||||
{
|
||||
await _workerClient.SetRepoImportFoldersAsync(_folders);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorReported?.Invoke(Loc.T("vm.repoImport.saveFailed", ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearRepos()
|
||||
|
||||
Reference in New Issue
Block a user