Adds playback preferences and auto-persisted playback state to user settings

This commit is contained in:
BinaryAlley committed 2026-10-15 21:09:38 +03:00
1 parent aab36dcd29
commit dd76309ded
81 files changed
+6102 -173

No files matched your search

@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -27,6 +28,13 @@ public class UserSettingsEntityFixture
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user, or not.</param>
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Optional. Whether the player keeps downloading a track while playback is paused, or not.</param>
/// <param name="shouldAutoplay">Optional. Whether the player continues playback at the end of an album or artist, or not.</param>
/// <param name="isGaplessPlaybackEnabled">Optional. Whether the player transitions between consecutive tracks without a gap, or not.</param>
/// <param name="replayGainMode">Optional. The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">Optional. The quality cap applied to the audio the server normalizes for the user.</param>
/// <param name="volume">Optional. The last volume the player reported for the user.</param>
/// <param name="isMuted">Optional. The last mute state the player reported for the user.</param>
/// <returns>The created user settings entity.</returns>
public UserSettingsEntity Create(
Guid? id = null,
@@ -37,7 +45,14 @@ public class UserSettingsEntityFixture
bool? isThemeCachingEnabled = null,
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null,
double? volume = null,
bool? isMuted = null)
{
return new Faker<UserSettingsEntity>()
.CustomInstantiator(f => new UserSettingsEntity
@@ -50,7 +65,14 @@ public class UserSettingsEntityFixture
IsThemeCachingEnabled = isThemeCachingEnabled ?? f.Random.Bool(),
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? f.Random.Bool(),
ShouldRenderPdfAsImages = shouldRenderPdfAsImages ?? f.Random.Bool(),
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? f.Random.Bool()
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? f.Random.Bool(),
ShouldKeepDownloadingWhilePaused = shouldKeepDownloadingWhilePaused ?? f.Random.Bool(),
ShouldAutoplay = shouldAutoplay ?? f.Random.Bool(),
IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled ?? f.Random.Bool(),
ReplayGainMode = replayGainMode ?? f.PickRandom<ReplayGainMode>(),
StreamingQuality = streamingQuality ?? f.PickRandom<PlaybackStreamingQuality>(),
Volume = volume ?? f.Random.Double(0.0, 1.0),
IsMuted = isMuted ?? f.Random.Bool()
})
.Generate();
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSettings;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -25,6 +26,11 @@ public class UpdateUserSettingsCommandFixture
/// <param name="shouldAggregateArtworkWhenMissing">Optional. Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Optional. Whether the player keeps downloading a track while playback is paused, or not.</param>
/// <param name="shouldAutoplay">Optional. Whether the player continues playback at the end of an album or artist, or not.</param>
/// <param name="isGaplessPlaybackEnabled">Optional. Whether the player transitions between consecutive tracks without a gap, or not.</param>
/// <param name="replayGainMode">Optional. The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">Optional. The quality cap applied to the audio the server normalizes for the user.</param>
/// <returns>The created command.</returns>
public UpdateUserSettingsCommand Create(
bool? isPaginationEnabled = null,
@@ -34,10 +40,15 @@ public class UpdateUserSettingsCommandFixture
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldAggregateArtworkWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null)
{
return new Faker<UpdateUserSettingsCommand>()
.CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default, default, default, default))
.CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default, default, default, default, default, default, default, default, default))
.RuleFor(x => x.IsPaginationEnabled, f => isPaginationEnabled ?? f.Random.Bool())
.RuleFor(x => x.ItemsPerPage, f => itemsPerPage ?? f.Random.Int(1, 100))
.RuleFor(x => x.ShouldIgnoreThePrefixForAlphaPicker, f => shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool())
@@ -46,6 +57,11 @@ public class UpdateUserSettingsCommandFixture
.RuleFor(x => x.ShouldAggregateArtworkWhenMissing, f => shouldAggregateArtworkWhenMissing ?? f.Random.Bool())
.RuleFor(x => x.ShouldRenderPdfAsImages, f => shouldRenderPdfAsImages ?? f.Random.Bool())
.RuleFor(x => x.ShouldPreserveBookStyles, f => shouldPreserveBookStyles ?? f.Random.Bool())
.RuleFor(x => x.ShouldKeepDownloadingWhilePaused, f => shouldKeepDownloadingWhilePaused ?? f.Random.Bool())
.RuleFor(x => x.ShouldAutoplay, f => shouldAutoplay ?? f.Random.Bool())
.RuleFor(x => x.IsGaplessPlaybackEnabled, f => isGaplessPlaybackEnabled ?? f.Random.Bool())
.RuleFor(x => x.ReplayGainMode, f => replayGainMode ?? f.PickRandom<ReplayGainMode>())
.RuleFor(x => x.StreamingQuality, f => streamingQuality ?? f.PickRandom<PlaybackStreamingQuality>())
.Generate();
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.UsersManagement.Settings;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -27,6 +28,11 @@ public class UpdateUserSettingsRequestFixture
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused.</param>
/// <param name="shouldAutoplay">Whether the player continues playback at the end of an album or artist.</param>
/// <param name="isGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap.</param>
/// <param name="replayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
/// <returns>The created <see cref="UpdateUserSettingsRequest"/>.</returns>
public UpdateUserSettingsRequest Create(
bool? isPaginationEnabled = null,
@@ -36,7 +42,12 @@ public class UpdateUserSettingsRequestFixture
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldAggregateArtworkWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null)
{
return new UpdateUserSettingsRequest(
isPaginationEnabled ?? _faker.Random.Bool(),
@@ -46,7 +57,12 @@ public class UpdateUserSettingsRequestFixture
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
shouldAggregateArtworkWhenMissing ?? _faker.Random.Bool(),
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
shouldPreserveBookStyles ?? _faker.Random.Bool());
shouldPreserveBookStyles ?? _faker.Random.Bool(),
shouldKeepDownloadingWhilePaused ?? _faker.Random.Bool(),
shouldAutoplay ?? _faker.Random.Bool(),
isGaplessPlaybackEnabled ?? _faker.Random.Bool(),
replayGainMode ?? _faker.PickRandom<ReplayGainMode>(),
streamingQuality ?? _faker.PickRandom<PlaybackStreamingQuality>());
}
/// <summary>
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.UsersManagement.Settings;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -29,6 +30,11 @@ public class UserSettingsResponseFixture
/// <param name="shouldAggregateArtworkWhenMissing">Optional. Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Optional. Whether the player keeps downloading a track while playback is paused.</param>
/// <param name="shouldAutoplay">Optional. Whether the player continues playback at the end of an album or artist.</param>
/// <param name="isGaplessPlaybackEnabled">Optional. Whether the player transitions between consecutive tracks without a gap.</param>
/// <param name="replayGainMode">Optional. The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">Optional. The quality cap applied to the audio the server normalizes for the user.</param>
/// <returns>The created <see cref="UserSettingsResponse"/>.</returns>
public UserSettingsResponse Create(
Guid? userId = null,
@@ -39,7 +45,12 @@ public class UserSettingsResponseFixture
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldAggregateArtworkWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null)
{
return new UserSettingsResponse(
userId ?? Guid.NewGuid(),
@@ -50,7 +61,12 @@ public class UserSettingsResponseFixture
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
shouldAggregateArtworkWhenMissing ?? _faker.Random.Bool(),
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
shouldPreserveBookStyles ?? _faker.Random.Bool());
shouldPreserveBookStyles ?? _faker.Random.Bool(),
shouldKeepDownloadingWhilePaused ?? _faker.Random.Bool(),
shouldAutoplay ?? _faker.Random.Bool(),
isGaplessPlaybackEnabled ?? _faker.Random.Bool(),
replayGainMode ?? _faker.PickRandom<ReplayGainMode>(),
streamingQuality ?? _faker.PickRandom<PlaybackStreamingQuality>());
}
/// <summary>
@@ -2,6 +2,7 @@
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -28,6 +29,13 @@ public class UserSettingsFixture
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused.</param>
/// <param name="shouldAutoplay">Whether the player continues playback at the end of an album or artist.</param>
/// <param name="isGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap.</param>
/// <param name="replayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
/// <param name="volume">The last volume the player reported for the user.</param>
/// <param name="isMuted">The last mute state the player reported for the user.</param>
/// <returns>The created <see cref="UserSettings"/>.</returns>
public UserSettings Create(
Guid? userId = null,
@@ -38,7 +46,14 @@ public class UserSettingsFixture
bool shouldAggregateMetadataWhenMissing = false,
bool shouldAggregateArtworkWhenMissing = false,
bool shouldRenderPdfAsImages = false,
bool shouldPreserveBookStyles = true)
bool shouldPreserveBookStyles = true,
bool shouldKeepDownloadingWhilePaused = true,
bool shouldAutoplay = true,
bool isGaplessPlaybackEnabled = true,
ReplayGainMode replayGainMode = ReplayGainMode.Off,
PlaybackStreamingQuality streamingQuality = PlaybackStreamingQuality.Auto,
double volume = 1.0,
bool isMuted = false)
{
Result<UserSettings> settings = UserSettings.Create(
userId is null ? UserId.CreateUnique() : UserId.Create(userId.Value),
@@ -49,7 +64,14 @@ public class UserSettingsFixture
shouldAggregateMetadataWhenMissing,
shouldAggregateArtworkWhenMissing,
shouldRenderPdfAsImages,
shouldPreserveBookStyles);
shouldPreserveBookStyles,
shouldKeepDownloadingWhilePaused,
shouldAutoplay,
isGaplessPlaybackEnabled,
replayGainMode,
streamingQuality,
volume,
isMuted);
return settings.Value;
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
using Lumina.Presentation.Web.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -28,6 +29,11 @@ public class UserSettingsDtoFixture
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused.</param>
/// <param name="shouldAutoplay">Whether the player continues playback at the end of an album or artist.</param>
/// <param name="isGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap.</param>
/// <param name="replayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
/// <returns>A configured <see cref="UserSettingsDto"/> instance.</returns>
public UserSettingsDto Create(
Guid? userId = null,
@@ -37,7 +43,12 @@ public class UserSettingsDtoFixture
bool? isThemeCachingEnabled = null,
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null)
{
return new UserSettingsDto
{
@@ -48,7 +59,12 @@ public class UserSettingsDtoFixture
IsThemeCachingEnabled = isThemeCachingEnabled ?? _faker.Random.Bool(),
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
ShouldRenderPdfAsImages = shouldRenderPdfAsImages ?? _faker.Random.Bool(),
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? _faker.Random.Bool()
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? _faker.Random.Bool(),
ShouldKeepDownloadingWhilePaused = shouldKeepDownloadingWhilePaused ?? _faker.Random.Bool(),
ShouldAutoplay = shouldAutoplay ?? _faker.Random.Bool(),
IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled ?? _faker.Random.Bool(),
ReplayGainMode = replayGainMode ?? _faker.PickRandom<ReplayGainMode>(),
StreamingQuality = streamingQuality ?? _faker.PickRandom<PlaybackStreamingQuality>()
};
}