From 38013c16d6665f3401c891de8225306a84942446 Mon Sep 17 00:00:00 2001 From: JT Date: Fri, 15 Mar 2024 18:04:55 -0700 Subject: [PATCH] Fix star ratings for civitai stuff --- .../ViewModels/Dialogs/RecommendedModelsViewModel.cs | 6 ++++-- StabilityMatrix.Avalonia/Views/CivitAiBrowserPage.axaml | 6 +++--- .../Views/Dialogs/RecommendedModelsDialog.axaml | 4 ++-- StabilityMatrix.Core/Models/Api/CivitModel.cs | 7 ++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/RecommendedModelsViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/RecommendedModelsViewModel.cs index 41750364..e037408e 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/RecommendedModelsViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/RecommendedModelsViewModel.cs @@ -97,9 +97,11 @@ public partial class RecommendedModelsViewModel : ContentDialogViewModelBase new RecommendedModelItemViewModel { ModelVersion = model.ModelVersions.First( - x => !x.BaseModel.Contains("Turbo", StringComparison.OrdinalIgnoreCase) + x => + !x.BaseModel.Contains("Turbo", StringComparison.OrdinalIgnoreCase) + && !x.BaseModel.Contains("Lightning", StringComparison.OrdinalIgnoreCase) ), - Author = $"by {model.Creator.Username}", + Author = $"by {model.Creator?.Username}", CivitModel = model } ) diff --git a/StabilityMatrix.Avalonia/Views/CivitAiBrowserPage.axaml b/StabilityMatrix.Avalonia/Views/CivitAiBrowserPage.axaml index ea6e563c..ba065242 100644 --- a/StabilityMatrix.Avalonia/Views/CivitAiBrowserPage.axaml +++ b/StabilityMatrix.Avalonia/Views/CivitAiBrowserPage.axaml @@ -319,11 +319,11 @@ Background="#66000000" FontSize="16" Foreground="{DynamicResource ThemeEldenRingOrangeColor}" - Value="{Binding CivitModel.Stats.Rating}" /> + Value="{Binding CivitModel.ModelVersionStats.Rating}" /> @@ -336,7 +336,7 @@ + Text="{Binding CivitModel.ModelVersionStats.FavoriteCount, Converter={StaticResource KiloFormatterConverter}}" /> + Value="{Binding ModelVersion.Stats.Rating}" /> diff --git a/StabilityMatrix.Core/Models/Api/CivitModel.cs b/StabilityMatrix.Core/Models/Api/CivitModel.cs index 26e1afb2..be381d0c 100644 --- a/StabilityMatrix.Core/Models/Api/CivitModel.cs +++ b/StabilityMatrix.Core/Models/Api/CivitModel.cs @@ -48,9 +48,7 @@ public class CivitModel var latestVersion = ModelVersions?.FirstOrDefault(); if (latestVersion?.Files != null && latestVersion.Files.Any()) { - var latestModelFile = latestVersion.Files.FirstOrDefault( - x => x.Type == CivitFileType.Model - ); + var latestModelFile = latestVersion.Files.FirstOrDefault(x => x.Type == CivitFileType.Model); kbs = latestModelFile?.SizeKb ?? 0; } fullFilesSize = new FileSizeType(kbs); @@ -65,4 +63,7 @@ public class CivitModel ModelVersions != null && ModelVersions.Any() ? ModelVersions[0].BaseModel?.Replace("SD", "").Trim() : string.Empty; + + public CivitModelStats ModelVersionStats => + ModelVersions != null && ModelVersions.Any() ? ModelVersions[0].Stats : new CivitModelStats(); }