New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect playlist sort order in watch-video-playlist
#5013
base: development
Are you sure you want to change the base?
Respect playlist sort order in watch-video-playlist
#5013
Conversation
I don't see the need for this particular sort order.
Context from absidue: 'I don't think we should even attempt to support it, due to all of the situations where it wouldn't be possible.'
…at/add-playlist-sort-order
…at/add-playlist-sort-order-2
…at/add-playlist-sort-order-2
Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
66d67ff
to
1cf9f7e
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
…at/add-playlist-sort-order-2
Conflicts have been resolved. A maintainer will review the pull request shortly. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
…at/add-playlist-sort-order-2
Conflicts have been resolved. A maintainer will review the pull request shortly. |
I'm still feeling shaky about the energy expenditure aspect of it, so I'm leaning towards shelving it this release and working on the performance suggestions. |
Update 5/23:
|
I think it's best to keep the current solution of sorting on demand, rather than storing the sorted playlist. It will also make adding a video to a playlist more expensive, as we'll have to sort the playlist every time you add a video to the playlist, regardless of what page you are on, instead of just if you are on the playlist or watch page. We can skip the first sort on the watch page by using the already sorted playlist from the playlists page, by using the cached playlist trick that we use for remote playlists (currently not done for the user playlists as we fetch them from the playlists store every time), where we pass through the videos from the playlist page to the watch page, by saving them to the utils store. You will still need to fetch it from the store and sort it if the user accesses the watch page directly (e.g. middle clicking on a video on the playlists page, which would open a new window right to the watch page). |
I'm seeing merit to what you're saying, although:
This isn't exactly true, to be pedantic. If you have the sorting applied in
This is definitely the right choice if we're to go this path. Thanks for this suggestion. |
Respect playlist sort order in watch-video-playlist
Pull Request Type
Related issue
#5008 (comment)
Description
Implements sort order for a given user playlist when opening it with watch-video-playlist. This ensures sort order is respected in the order it was presented on the Playlists page.
Screenshots
Testing
watch-video-playlist
for arbitrary sortDesktop
Additional context
Playlist sort is computed when the user playlist in
watch-video-playlist
is first loaded and when it is updated with additions / removals during that session. While this is not necessarily having an apparent performance effect in my testing, I would imagine it's at least a potential concern w.r.t. sum power draw across our user base.As it stands, the O(nlogn) sorting operation is executed for each playlist load, or upon each addition/removal to a playlist while it is currently being watched. In the future, 1) we may want to consider adding an ordering property to playlistItems for the custom sort order instead of relying on its default order, 2) thus allowing the "sort" action to be one-and-done per sort preference change by storing that playlist in its sort preference, and 3) using binary search for each subsequent insertion into a playlist. This would remove the O(nlogn) operation upon each playlist load, and it would reduce the addition cost to O(klogn), where k is the number of elements being added.