Browse Source

Merge pull request #574 from ionite34/backport/main/pr-573

[dev to main] backport: Fix star ratings for civitai stuff (573)
pull/530/head
JT 8 months ago committed by GitHub
parent
commit
8810e18ef6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  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 new RecommendedModelItemViewModel
{ {
ModelVersion = model.ModelVersions.First( 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 CivitModel = model
} }
) )

6
StabilityMatrix.Avalonia/Views/CivitAiBrowserPage.axaml

@ -319,11 +319,11 @@
Background="#66000000" Background="#66000000"
FontSize="16" FontSize="16"
Foreground="{DynamicResource ThemeEldenRingOrangeColor}" Foreground="{DynamicResource ThemeEldenRingOrangeColor}"
Value="{Binding CivitModel.Stats.Rating}" /> Value="{Binding CivitModel.ModelVersionStats.Rating}" />
<TextBlock <TextBlock
Margin="4,0,0,0" Margin="4,0,0,0"
VerticalAlignment="Center" VerticalAlignment="Center"
Text="{Binding CivitModel.Stats.RatingCount}" Text="{Binding CivitModel.ModelVersionStats.RatingCount}"
TextAlignment="Center" /> TextAlignment="Center" />
</StackPanel> </StackPanel>
@ -336,7 +336,7 @@
<TextBlock <TextBlock
Margin="4,0" Margin="4,0"
VerticalAlignment="Center" 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" /> <avalonia:Icon Margin="4,0" Value="fa-solid fa-download" />
<TextBlock <TextBlock

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

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

7
StabilityMatrix.Core/Models/Api/CivitModel.cs

@ -48,9 +48,7 @@ public class CivitModel
var latestVersion = ModelVersions?.FirstOrDefault(); var latestVersion = ModelVersions?.FirstOrDefault();
if (latestVersion?.Files != null && latestVersion.Files.Any()) if (latestVersion?.Files != null && latestVersion.Files.Any())
{ {
var latestModelFile = latestVersion.Files.FirstOrDefault( var latestModelFile = latestVersion.Files.FirstOrDefault(x => x.Type == CivitFileType.Model);
x => x.Type == CivitFileType.Model
);
kbs = latestModelFile?.SizeKb ?? 0; kbs = latestModelFile?.SizeKb ?? 0;
} }
fullFilesSize = new FileSizeType(kbs); fullFilesSize = new FileSizeType(kbs);
@ -65,4 +63,7 @@ public class CivitModel
ModelVersions != null && ModelVersions.Any() ModelVersions != null && ModelVersions.Any()
? ModelVersions[0].BaseModel?.Replace("SD", "").Trim() ? ModelVersions[0].BaseModel?.Replace("SD", "").Trim()
: string.Empty; : string.Empty;
public CivitModelStats ModelVersionStats =>
ModelVersions != null && ModelVersions.Any() ? ModelVersions[0].Stats : new CivitModelStats();
} }

Loading…
Cancel
Save