Browse Source

Fix star ratings for civitai stuff

pull/629/head
JT 8 months ago
parent
commit
38013c16d6
  1. 6
      StabilityMatrix.Avalonia/ViewModels/Dialogs/RecommendedModelsViewModel.cs
  2. 6
      StabilityMatrix.Avalonia/Views/CivitAiBrowserPage.axaml
  3. 4
      StabilityMatrix.Avalonia/Views/Dialogs/RecommendedModelsDialog.axaml
  4. 7
      StabilityMatrix.Core/Models/Api/CivitModel.cs

6
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
}
)

6
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}" />
<TextBlock
Margin="4,0,0,0"
VerticalAlignment="Center"
Text="{Binding CivitModel.Stats.RatingCount}"
Text="{Binding CivitModel.ModelVersionStats.RatingCount}"
TextAlignment="Center" />
</StackPanel>
@ -336,7 +336,7 @@
<TextBlock
Margin="4,0"
VerticalAlignment="Center"
Text="{Binding CivitModel.Stats.FavoriteCount, Converter={StaticResource KiloFormatterConverter}}" />
Text="{Binding CivitModel.ModelVersionStats.FavoriteCount, Converter={StaticResource KiloFormatterConverter}}" />
<avalonia:Icon Margin="4,0" Value="fa-solid fa-download" />
<TextBlock

4
StabilityMatrix.Avalonia/Views/Dialogs/RecommendedModelsDialog.axaml

@ -110,11 +110,11 @@
Background="#66000000"
FontSize="16"
Foreground="{DynamicResource ThemeEldenRingOrangeColor}"
Value="{Binding CivitModel.Stats.Rating}" />
Value="{Binding ModelVersion.Stats.Rating}" />
<TextBlock
Margin="4,0,0,0"
VerticalAlignment="Center"
Text="{Binding CivitModel.Stats.RatingCount}"
Text="{Binding ModelVersion.Stats.RatingCount}"
TextAlignment="Center" />
</StackPanel>
</StackPanel>

7
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();
}

Loading…
Cancel
Save