diff options
| author | Kevin G <kevin@myplaceonline.com> | 2025-10-23 19:27:34 -0500 |
|---|---|---|
| committer | Kevin G <kevin@myplaceonline.com> | 2025-10-23 19:27:34 -0500 |
| commit | 79061f463507b98f8b03db3431d23789d90de412 (patch) | |
| tree | 079d68dee06695e0dd50038a07d560d03dd11f63 /Emby.Server.Implementations | |
| parent | cd9154f1100f2133fc4f8aaa4d021c1848222e32 (diff) | |
Change moveToTop in AddItemToPlaylistAsync to 0-based position
Signed-off-by: Kevin G <kevin@myplaceonline.com>
Diffstat (limited to 'Emby.Server.Implementations')
| -rw-r--r-- | Emby.Server.Implementations/Playlists/PlaylistManager.cs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 6ce2883d1..4538fc6a3 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -198,7 +198,7 @@ namespace Emby.Server.Implementations.Playlists return Playlist.GetPlaylistItems(items, user, options); } - public Task AddItemToPlaylistAsync(Guid playlistId, IReadOnlyCollection<Guid> itemIds, bool? moveToTop, Guid userId) + public Task AddItemToPlaylistAsync(Guid playlistId, IReadOnlyCollection<Guid> itemIds, int? position, Guid userId) { var user = userId.IsEmpty() ? null : _userManager.GetUserById(userId); @@ -210,10 +210,10 @@ namespace Emby.Server.Implementations.Playlists { EnableImages = true }, - moveToTop); + position); } - private async Task AddToPlaylistInternal(Guid playlistId, IReadOnlyCollection<Guid> newItemIds, User user, DtoOptions options, bool? moveToTop = null) + private async Task AddToPlaylistInternal(Guid playlistId, IReadOnlyCollection<Guid> newItemIds, User user, DtoOptions options, int? position = null) { // Retrieve the existing playlist var playlist = _libraryManager.GetItemById(playlistId) as Playlist @@ -248,9 +248,24 @@ namespace Emby.Server.Implementations.Playlists } // Update the playlist in the repository - if (moveToTop.HasValue && moveToTop.Value) + if (position.HasValue) { - playlist.LinkedChildren = [.. childrenToAdd, .. playlist.LinkedChildren]; + if (position.Value <= 0) + { + playlist.LinkedChildren = [.. childrenToAdd, .. playlist.LinkedChildren]; + } + else if (position.Value >= playlist.LinkedChildren.Length) + { + playlist.LinkedChildren = [.. playlist.LinkedChildren, .. childrenToAdd]; + } + else + { + playlist.LinkedChildren = [ + .. playlist.LinkedChildren[0..position.Value], + .. childrenToAdd, + .. playlist.LinkedChildren[position.Value..playlist.LinkedChildren.Length] + ]; + } } else { |
