Merge pull request #1317 from Mbucari/master

Bug fixes and UI tweak
This commit is contained in:
rmcrackan 2025-07-29 07:52:01 -04:00 committed by GitHub
commit c82eefa768
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 59 additions and 22 deletions

View File

@ -241,7 +241,7 @@ namespace DataLayer
{ {
// don't overwrite with default values // don't overwrite with default values
IsAbridged |= isAbridged; IsAbridged |= isAbridged;
IsSpatial |= isSpatial ?? false; IsSpatial = isSpatial ?? IsSpatial;
DatePublished = datePublished ?? DatePublished; DatePublished = datePublished ?? DatePublished;
Language = language?.FirstCharToUpper() ?? Language; Language = language?.FirstCharToUpper() ?? Language;
} }

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using AudibleUtilities; using AudibleUtilities;
using DataLayer; using DataLayer;
using Dinah.Core; using Dinah.Core;
using LibationFileManager;
using LibationFileManager.Templates; using LibationFileManager.Templates;
#nullable enable #nullable enable
@ -66,7 +67,7 @@ namespace FileLiberator
BitRate = libraryBook.Book.UserDefinedItem.LastDownloadedFormat?.BitRate, BitRate = libraryBook.Book.UserDefinedItem.LastDownloadedFormat?.BitRate,
SampleRate = libraryBook.Book.UserDefinedItem.LastDownloadedFormat?.SampleRate, SampleRate = libraryBook.Book.UserDefinedItem.LastDownloadedFormat?.SampleRate,
Channels = libraryBook.Book.UserDefinedItem.LastDownloadedFormat?.ChannelCount, Channels = libraryBook.Book.UserDefinedItem.LastDownloadedFormat?.ChannelCount,
LibationVersion = libraryBook.Book.UserDefinedItem.LastDownloadedVersion?.ToString(3), LibationVersion = libraryBook.Book.UserDefinedItem.LastDownloadedVersion?.ToVersionString(),
FileVersion = libraryBook.Book.UserDefinedItem.LastDownloadedFileVersion FileVersion = libraryBook.Book.UserDefinedItem.LastDownloadedFileVersion
}; };
} }

View File

@ -61,7 +61,7 @@ namespace LibationAvalonia.Dialogs
private void Link_getlibation(object sender, Avalonia.Input.TappedEventArgs e) => Dinah.Core.Go.To.Url(AppScaffolding.LibationScaffolding.WebsiteUrl); private void Link_getlibation(object sender, Avalonia.Input.TappedEventArgs e) => Dinah.Core.Go.To.Url(AppScaffolding.LibationScaffolding.WebsiteUrl);
private void ViewReleaseNotes_Tapped(object sender, Avalonia.Input.TappedEventArgs e) private void ViewReleaseNotes_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
=> Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{AppScaffolding.LibationScaffolding.BuildVersion.ToString(3)}"); => Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{AppScaffolding.LibationScaffolding.BuildVersion.ToVersionString()}");
} }
public class AboutVM : ViewModelBase public class AboutVM : ViewModelBase

View File

@ -1,6 +1,7 @@
using AppScaffolding; using AppScaffolding;
using Avalonia.Controls; using Avalonia.Controls;
using Dinah.Core; using Dinah.Core;
using LibationFileManager;
using LibationUiBase.Forms; using LibationUiBase.Forms;
namespace LibationAvalonia.Dialogs namespace LibationAvalonia.Dialogs
@ -30,7 +31,7 @@ namespace LibationAvalonia.Dialogs
public UpgradeNotificationDialog(UpgradeProperties upgradeProperties, bool canUpgrade) : this() public UpgradeNotificationDialog(UpgradeProperties upgradeProperties, bool canUpgrade) : this()
{ {
Title = $"Libation version {upgradeProperties.LatestRelease.ToString(3)} is now available."; Title = $"Libation version {upgradeProperties.LatestRelease.ToVersionString()} is now available.";
PackageUrl = upgradeProperties.ZipUrl; PackageUrl = upgradeProperties.ZipUrl;
DownloadLinkText = upgradeProperties.ZipName; DownloadLinkText = upgradeProperties.ZipName;
ReleaseNotes = upgradeProperties.Notes; ReleaseNotes = upgradeProperties.Notes;

View File

@ -1,6 +1,7 @@
using AppScaffolding; using AppScaffolding;
using CommandLine; using CommandLine;
using CommandLine.Text; using CommandLine.Text;
using LibationFileManager;
namespace LibationCli; namespace LibationCli;
@ -20,7 +21,7 @@ internal class HelpVerb
{ {
AutoVersion = false, AutoVersion = false,
AutoHelp = false, AutoHelp = false,
Heading = $"LibationCli v{LibationScaffolding.BuildVersion.ToString(3)}", Heading = $"LibationCli v{LibationScaffolding.BuildVersion.ToVersionString()}",
AdditionalNewLineAfterOption = true, AdditionalNewLineAfterOption = true,
MaximumDisplayWidth = 80 MaximumDisplayWidth = 80
}; };

View File

@ -1,5 +1,6 @@
using AppScaffolding; using AppScaffolding;
using CommandLine; using CommandLine;
using LibationFileManager;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -14,7 +15,7 @@ internal class VersionOptions : OptionsBase
protected override Task ProcessAsync() protected override Task ProcessAsync()
{ {
const string checkingForUpgrade = "Checking for upgrade..."; const string checkingForUpgrade = "Checking for upgrade...";
Console.WriteLine($"Libation {LibationScaffolding.Variety} v{LibationScaffolding.BuildVersion.ToString(3)}"); Console.WriteLine($"Libation {LibationScaffolding.Variety} v{LibationScaffolding.BuildVersion.ToVersionString()}");
if (CheckForUpgrade) if (CheckForUpgrade)
{ {
@ -34,7 +35,7 @@ internal class VersionOptions : OptionsBase
else else
{ {
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
ReplaceConsoleText(Console.Out, checkingForUpgrade.Length, $"Upgrade Available: v{upgradeProperties.LatestRelease.ToString(3)}"); ReplaceConsoleText(Console.Out, checkingForUpgrade.Length, $"Upgrade Available: v{upgradeProperties.LatestRelease.ToVersionString()}");
Console.WriteLine(); Console.WriteLine();
Console.WriteLine(); Console.WriteLine();
Console.WriteLine(upgradeProperties.ZipUrl); Console.WriteLine(upgradeProperties.ZipUrl);

View File

@ -16,6 +16,11 @@ namespace LibationFileManager
MacOS = 0x400000, MacOS = 0x400000,
} }
public static class Estensions
{
public static string ToVersionString(this Version version) => version.Revision > 1 ? version.ToString(4) : version.ToString(3);
}
public partial class Configuration public partial class Configuration
{ {
public static bool IsWindows { get; } = OperatingSystem.IsWindows(); public static bool IsWindows { get; } = OperatingSystem.IsWindows();

View File

@ -70,7 +70,7 @@ namespace LibationFileManager.Templates
Narrators = [new("Stephen Fry", null)], Narrators = [new("Stephen Fry", null)],
Series = [new("Sherlock Holmes", 1, "B08376S3R2"), new("Some Other Series", 1, "B000000000")], Series = [new("Sherlock Holmes", 1, "B08376S3R2"), new("Some Other Series", 1, "B000000000")],
Codec = "AAC-LC", Codec = "AAC-LC",
LibationVersion = Configuration.LibationVersion?.ToString(3), LibationVersion = Configuration.LibationVersion?.ToVersionString(),
FileVersion = "36217811", FileVersion = "36217811",
BitRate = 128, BitRate = 128,
SampleRate = 44100, SampleRate = 44100,

View File

@ -211,6 +211,24 @@ namespace LibationUiBase.GridView
_ => null _ => null
}; };
public bool MemberValueIsDefault(string memberName) => memberName switch
{
nameof(Series) => Book.SeriesLink?.Any() is not true,
nameof(SeriesOrder) => string.IsNullOrWhiteSpace(SeriesOrder.OrderString),
nameof(MyRating) => RatingIsDefault(Book.UserDefinedItem.Rating),
nameof(ProductRating) => RatingIsDefault(Book.Rating),
nameof(Authors) => string.IsNullOrWhiteSpace(Authors),
nameof(Narrators) => string.IsNullOrWhiteSpace(Narrators),
nameof(Description) => string.IsNullOrWhiteSpace(Description),
nameof(Category) => string.IsNullOrWhiteSpace(Category),
nameof(Misc) => string.IsNullOrWhiteSpace(Misc),
nameof(BookTags) => string.IsNullOrWhiteSpace(BookTags),
_ => false
};
private static bool RatingIsDefault(Rating rating)
=> rating is null || (rating.OverallRating == 0 && rating.PerformanceRating == 0 && rating.StoryRating == 0);
public IComparer GetMemberComparer(Type memberType) public IComparer GetMemberComparer(Type memberType)
=> memberTypeComparers.TryGetValue(memberType, out IComparer value) ? value : memberTypeComparers[memberType.BaseType]; => memberTypeComparers.TryGetValue(memberType, out IComparer value) ? value : memberTypeComparers[memberType.BaseType];
@ -341,7 +359,6 @@ namespace LibationUiBase.GridView
return (await Task.WhenAll(tasks)).SelectMany(a => a).ToList(); return (await Task.WhenAll(tasks)).SelectMany(a => a).ToList();
} }
~GridEntry() ~GridEntry()
{ {
PictureStorage.PictureCached -= PictureStorage_PictureCached; PictureStorage.PictureCached -= PictureStorage_PictureCached;

View File

@ -1,4 +1,5 @@
using DataLayer; using DataLayer;
using LibationFileManager;
using System; using System;
namespace LibationUiBase.GridView namespace LibationUiBase.GridView
@ -10,7 +11,7 @@ namespace LibationUiBase.GridView
public string LastDownloadedFileVersion { get; } public string LastDownloadedFileVersion { get; }
public Version LastDownloadedVersion { get; } public Version LastDownloadedVersion { get; }
public DateTime? LastDownloaded { get; } public DateTime? LastDownloaded { get; }
public string ToolTipText => IsValid ? $"Double click to open v{LastDownloadedVersion.ToString(3)} release notes" : ""; public string ToolTipText => IsValid ? $"Double click to open v{LastDownloadedVersion.ToVersionString()} release notes" : "";
public LastDownloadStatus() { } public LastDownloadStatus() { }
public LastDownloadStatus(UserDefinedItem udi) public LastDownloadStatus(UserDefinedItem udi)
@ -24,14 +25,14 @@ namespace LibationUiBase.GridView
public void OpenReleaseUrl() public void OpenReleaseUrl()
{ {
if (IsValid) if (IsValid)
Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{LastDownloadedVersion.ToString(3)}"); Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{LastDownloadedVersion.ToVersionString()}");
} }
public override string ToString() public override string ToString()
=> IsValid ? $""" => IsValid ? $"""
{dateString()} {versionString()} {dateString()} {versionString()}
{LastDownloadedFormat} {LastDownloadedFormat}
Libation v{LastDownloadedVersion.ToString(3)} Libation v{LastDownloadedVersion.ToVersionString()}
""" : ""; """ : "";
private string versionString() => LastDownloadedFileVersion is string ver ? $"(File v.{ver})" : ""; private string versionString() => LastDownloadedFileVersion is string ver ? $"(File v.{ver})" : "";

View File

@ -20,10 +20,18 @@ namespace LibationUiBase.GridView
protected abstract ListSortDirection GetSortOrder(); protected abstract ListSortDirection GetSortOrder();
private int InternalCompare(GridEntry x, GridEntry y) private int InternalCompare(GridEntry x, GridEntry y)
{
//Default values (e.g. empty strings) always sort to the end of the list.
var val1IsDefault = x.MemberValueIsDefault(PropertyName);
var val2IsDefault = y.MemberValueIsDefault(PropertyName);
if (val1IsDefault && val2IsDefault) return 0;
else if (val1IsDefault && !val2IsDefault) return GetSortOrder() is ListSortDirection.Ascending ? 1 : -1;
else if (!val1IsDefault && val2IsDefault) return GetSortOrder() is ListSortDirection.Ascending ? -1 : 1;
else
{ {
var val1 = x.GetMemberValue(PropertyName); var val1 = x.GetMemberValue(PropertyName);
var val2 = y.GetMemberValue(PropertyName); var val2 = y.GetMemberValue(PropertyName);
var compare = x.GetMemberComparer(val1.GetType()).Compare(val1, val2); var compare = x.GetMemberComparer(val1.GetType()).Compare(val1, val2);
return compare == 0 && x.Liberate.IsSeries && y.Liberate.IsSeries return compare == 0 && x.Liberate.IsSeries && y.Liberate.IsSeries
@ -31,6 +39,7 @@ namespace LibationUiBase.GridView
? x.AudibleProductId.CompareTo(y.AudibleProductId) ? x.AudibleProductId.CompareTo(y.AudibleProductId)
: compare; : compare;
} }
}
public int Compare(GridEntry? geA, GridEntry? geB) public int Compare(GridEntry? geA, GridEntry? geB)
{ {

View File

@ -1,4 +1,5 @@
using LibationUiBase; using LibationFileManager;
using LibationUiBase;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -38,7 +39,7 @@ namespace LibationWinForms.Dialogs
} }
private void releaseNotesLbl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) private void releaseNotesLbl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
=> Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{AppScaffolding.LibationScaffolding.BuildVersion.ToString(3)}"); => Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{AppScaffolding.LibationScaffolding.BuildVersion.ToVersionString()}");
private async void checkForUpgradeBtn_Click(object sender, EventArgs e) private async void checkForUpgradeBtn_Click(object sender, EventArgs e)
{ {

View File

@ -18,7 +18,7 @@ namespace LibationWinForms.Dialogs
public UpgradeNotificationDialog(UpgradeProperties upgradeProperties) : this() public UpgradeNotificationDialog(UpgradeProperties upgradeProperties) : this()
{ {
Text = $"Libation version {upgradeProperties.LatestRelease.ToString(3)} is now available."; Text = $"Libation version {upgradeProperties.LatestRelease.ToVersionString()} is now available.";
PackageUrl = upgradeProperties.ZipUrl; PackageUrl = upgradeProperties.ZipUrl;
packageDlLink.Text = upgradeProperties.ZipName; packageDlLink.Text = upgradeProperties.ZipName;
releaseNotesTbox.Text = upgradeProperties.Notes; releaseNotesTbox.Text = upgradeProperties.Notes;