refactor: simplify Playlist and NextMediaList construction - #909
Open
huynhsontung wants to merge 2 commits into
Open
refactor: simplify Playlist and NextMediaList construction#909huynhsontung wants to merge 2 commits into
huynhsontung wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors playlist construction to be index-based (instead of item-based) and simplifies NextMediaList creation by inferring NextItem from the first list entry.
Changes:
- Replaced
new Playlist(currentItem, items)usage withnew Playlist(currentIndex, items)across view models and services. - Added
NextMediaList(List<MediaViewModel> items)constructor and updated factories to use it. - Removed the
Playlist(MediaViewModel currentItem, ...)constructor.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Screenbox.Core/ViewModels/PlaylistDetailsPageViewModel.cs | Constructs playlists using the selected item’s index. |
| Screenbox.Core/ViewModels/MediaListViewModel.cs | Uses index-based playlist creation during parse-and-play flows. |
| Screenbox.Core/Services/PlaylistService.cs | Switches to index-based playlist creation when merging neighboring files / restoring from shuffle. |
| Screenbox.Core/Services/PlaybackControlService.cs | Creates playlists for previous/next navigation using an explicit index. |
| Screenbox.Core/Models/Playlist.cs | Removes item-based constructor and keeps index-based constructor. |
| Screenbox.Core/Models/NextMediaList.cs | Adds constructor that infers NextItem from items[0]. |
| Screenbox.Core/Helpers/MessengerExtensions.cs | Manually finds the media index before constructing a playlist. |
| Screenbox.Core/Factories/MediaListFactory.cs | Returns NextMediaList via list-only constructor to reduce repetition. |
Comments suppressed due to low confidence (1)
Screenbox.Core/Models/Playlist.cs:1
- Removing the public
Playlist(MediaViewModel currentItem, ...)constructor is a breaking API change for any external callers. If this assembly is consumed outside this project, consider keeping the old overload as a wrapper (possibly marked[Obsolete]) that forwards to the index-based constructor, so consumers can migrate without immediate breakage.
#nullable enable
| } | ||
| } | ||
|
|
||
| var playlist = new Playlist(index, queue); |
| { | ||
| var result = await _mediaListFactory.ParseMediaListAsync(nextFile); | ||
| var newPlaylist = new Playlist(result.NextItem, result.Items, playlist); | ||
| var newPlaylist = new Playlist(0, result.Items, playlist); |
| { | ||
| var result = await _mediaListFactory.ParseMediaListAsync(previousFile); | ||
| var newPlaylist = new Playlist(result.NextItem, result.Items, playlist); | ||
| var newPlaylist = new Playlist(0, result.Items, playlist); |
| Items = items; | ||
| } | ||
|
|
||
| public NextMediaList(List<MediaViewModel> items) : this(items[0], items) { } |
| // same object reference. Calling ParseMediaListAsync(file) would create a second VM | ||
| // via GetOrCreate, making result.NextItem a different instance from fileMedia. | ||
| // That mismatch would cause LoadFromPlaylist to restart playback unnecessarily. | ||
| result = await _mediaListFactory.ParseMediaListAsync(fileMedia); |
huynhsontung
force-pushed
the
safer-playlist-and-media-list
branch
from
May 26, 2026 05:26
556d281 to
fc332ce
Compare
huynhsontung
force-pushed
the
safer-playlist-and-media-list
branch
from
May 26, 2026 05:28
fc332ce to
378a4e9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.