Highlight active playlist. Various optimizations and fixes.

This commit is contained in:
2026-08-05 00:50:56 -04:00
parent 3c3cf37cd5
commit 1d45826c38
14 changed files with 327 additions and 55 deletions

View File

@@ -0,0 +1,60 @@
using Harmonia.Core.Models;
namespace Harmonia.Core.Playlists;
internal sealed record PlaylistDto
{
public string UID { get; init; } = Guid.NewGuid().ToString();
public string? Name { get; init; }
public List<PlaylistSongDto> Songs { get; init; } = [];
public List<GroupOption> GroupOptions { get; init; } = [];
public List<SortOption> SortOptions { get; init; } = [];
public bool IsLocked { get; init; }
public static PlaylistDto FromPlaylist(Playlist playlist)
{
return new PlaylistDto
{
UID = playlist.UID,
Name = playlist.Name,
Songs = [.. playlist.Songs.Select(PlaylistSongDto.FromPlaylistSong)],
GroupOptions = [.. playlist.GroupOptions],
SortOptions = [.. playlist.SortOptions],
IsLocked = playlist.IsLocked
};
}
public Playlist ToPlaylist()
{
return Playlist.Restore(
UID,
Name,
Songs.Select(song => song.ToPlaylistSong()),
GroupOptions,
SortOptions,
IsLocked);
}
}
internal sealed record PlaylistSongDto
{
public string UID { get; init; } = Guid.NewGuid().ToString();
public required Song Song { get; init; }
public static PlaylistSongDto FromPlaylistSong(PlaylistSong playlistSong)
{
return new PlaylistSongDto
{
UID = playlistSong.UID,
Song = playlistSong.Song
};
}
public PlaylistSong ToPlaylistSong()
{
return new PlaylistSong(Song)
{
UID = UID
};
}
}