You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.2 KiB
30 lines
1.2 KiB
using System.Collections.Generic; |
|
using System.Collections.ObjectModel; |
|
using System.Linq; |
|
using CommunityToolkit.Mvvm.ComponentModel; |
|
using StabilityMatrix.Core.Models.Api; |
|
using StabilityMatrix.Core.Services; |
|
|
|
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; |
|
|
|
public partial class ModelVersionViewModel : ObservableObject |
|
{ |
|
[ObservableProperty] private CivitModelVersion modelVersion; |
|
[ObservableProperty] private ObservableCollection<CivitFileViewModel> civitFileViewModels; |
|
[ObservableProperty] private bool isInstalled; |
|
|
|
public ModelVersionViewModel(ISettingsManager settingsManager, CivitModelVersion modelVersion) |
|
{ |
|
ModelVersion = modelVersion; |
|
|
|
var installedModelHashes = settingsManager.Settings.InstalledModelHashes; |
|
IsInstalled = ModelVersion.Files?.Any(file => |
|
file is {Type: CivitFileType.Model, Hashes.BLAKE3: not null} && |
|
installedModelHashes.Contains(file.Hashes.BLAKE3)) ?? |
|
false; |
|
|
|
CivitFileViewModels = new ObservableCollection<CivitFileViewModel>( |
|
ModelVersion.Files?.Select(file => new CivitFileViewModel(settingsManager, file)) ?? |
|
new List<CivitFileViewModel>()); |
|
} |
|
}
|
|
|