diff --git a/StabilityMatrix.Avalonia/App.axaml.cs b/StabilityMatrix.Avalonia/App.axaml.cs index 2a60ce21..63bf7079 100644 --- a/StabilityMatrix.Avalonia/App.axaml.cs +++ b/StabilityMatrix.Avalonia/App.axaml.cs @@ -398,6 +398,7 @@ public sealed class App : Application services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(provider => diff --git a/StabilityMatrix.Avalonia/DesignData/DesignData.cs b/StabilityMatrix.Avalonia/DesignData/DesignData.cs index dec2a7fa..7c83f83f 100644 --- a/StabilityMatrix.Avalonia/DesignData/DesignData.cs +++ b/StabilityMatrix.Avalonia/DesignData/DesignData.cs @@ -98,6 +98,7 @@ public static class DesignData .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton() .AddSingleton(); // Placeholder services that nobody should need during design time diff --git a/StabilityMatrix.Avalonia/DesignData/MockLiteDbContext.cs b/StabilityMatrix.Avalonia/DesignData/MockLiteDbContext.cs index c102805c..3b56d19a 100644 --- a/StabilityMatrix.Avalonia/DesignData/MockLiteDbContext.cs +++ b/StabilityMatrix.Avalonia/DesignData/MockLiteDbContext.cs @@ -14,6 +14,8 @@ public class MockLiteDbContext : ILiteDbContext public ILiteCollectionAsync CivitModels => throw new NotImplementedException(); public ILiteCollectionAsync CivitModelVersions => throw new NotImplementedException(); public ILiteCollectionAsync CivitModelQueryCache => throw new NotImplementedException(); + public ILiteCollectionAsync LocalModelFiles => throw new NotImplementedException(); + public Task<(CivitModel?, CivitModelVersion?)> FindCivitModelFromFileHashAsync(string hashBlake3) { return Task.FromResult<(CivitModel?, CivitModelVersion?)>((null, null)); diff --git a/StabilityMatrix.Avalonia/DesignData/MockModelIndexService.cs b/StabilityMatrix.Avalonia/DesignData/MockModelIndexService.cs new file mode 100644 index 00000000..ab52abf8 --- /dev/null +++ b/StabilityMatrix.Avalonia/DesignData/MockModelIndexService.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using StabilityMatrix.Core.Models; +using StabilityMatrix.Core.Models.Database; +using StabilityMatrix.Core.Services; + +namespace StabilityMatrix.Avalonia.DesignData; + +public class MockModelIndexService : IModelIndexService +{ + /// + public Task RefreshIndex() + { + return Task.CompletedTask; + } + + /// + public Task> GetModelsOfType(SharedFolderType type) + { + return Task.FromResult>(new List()); + } + + /// + public void BackgroundRefreshIndex() + { + } +} diff --git a/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs index 8fc3b7d5..de507dc9 100644 --- a/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs @@ -59,6 +59,7 @@ public partial class SettingsViewModel : PageViewModelBase private readonly ServiceManager dialogFactory; private readonly ICompletionProvider completionProvider; private readonly ITrackedDownloadService trackedDownloadService; + private readonly IModelIndexService modelIndexService; public SharedState SharedState { get; } @@ -133,7 +134,8 @@ public partial class SettingsViewModel : PageViewModelBase ServiceManager dialogFactory, ITrackedDownloadService trackedDownloadService, SharedState sharedState, - ICompletionProvider completionProvider) + ICompletionProvider completionProvider, + IModelIndexService modelIndexService) { this.notificationService = notificationService; this.settingsManager = settingsManager; @@ -142,7 +144,8 @@ public partial class SettingsViewModel : PageViewModelBase this.dialogFactory = dialogFactory; this.trackedDownloadService = trackedDownloadService; this.completionProvider = completionProvider; - + this.modelIndexService = modelIndexService; + SharedState = sharedState; SelectedTheme = settingsManager.Settings.Theme ?? AvailableThemes[1]; @@ -678,6 +681,12 @@ public partial class SettingsViewModel : PageViewModelBase notificationService.Show("Loaded completion file", ""); } + [RelayCommand] + private async Task DebugRefreshModelsIndex() + { + await modelIndexService.RefreshIndex(); + } + [RelayCommand] private async Task DebugTrackedDownload() { diff --git a/StabilityMatrix.Avalonia/Views/SettingsPage.axaml b/StabilityMatrix.Avalonia/Views/SettingsPage.axaml index ce231a9a..bc266bfe 100644 --- a/StabilityMatrix.Avalonia/Views/SettingsPage.axaml +++ b/StabilityMatrix.Avalonia/Views/SettingsPage.axaml @@ -366,6 +366,18 @@ + + +