Skip to content
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

Add sort options to playback requests #4786

Merged
merged 16 commits into from
Oct 18, 2023

Conversation

v0idMrK
Copy link
Contributor

@v0idMrK v0idMrK commented Sep 17, 2023

Changes
Added getting the SortOptions on shortcuts.js and list.js files and sending them in the playbackmanager.js play method

Issues
Fixes #4841

@v0idMrK v0idMrK requested a review from a team as a code owner September 17, 2023 22:30
CONTRIBUTORS.md Outdated Show resolved Hide resolved
src/components/shortcuts.js Show resolved Hide resolved
src/components/playback/playbackmanager.js Outdated Show resolved Hide resolved
Adds shortcuts.js function to get sort order
Added sort order technique to most types of media on playbackmanager.js
@v0idMrK
Copy link
Contributor Author

v0idMrK commented Sep 18, 2023

@dmitrylyzo Just updated this with improvements suggested by your comments.

Also added the same technique to the other media types on playbackmanager.js. Tested them and they seemed to work fine.

Please let me know if you have any other sugestion! Thank you

Copy link
Contributor

@dmitrylyzo dmitrylyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add sort here (Play in the context menu):

playbackManager[method]({
items: [item],
startPositionTicks: startPosition
});

src/components/shortcuts.js Outdated Show resolved Hide resolved
src/components/shortcuts.js Outdated Show resolved Hide resolved
@v0idMrK
Copy link
Contributor Author

v0idMrK commented Sep 19, 2023

@dmitrylyzo Hey, applied the changes. Let me know if anything else is missing :D

Thank you for your feedback.

@dmitrylyzo
Copy link
Contributor

Let me know if anything else is missing

We should add sort for Play in the context menu: #4786 (review)
At least I didn't notice any more.

There is also adding to the play queue, but it doesn't work for photos, so we can leave it for the future.

@grafixeyehero
Copy link
Member

grafixeyehero commented Sep 20, 2023

@dmitrylyzo @v0idMrK
A quick Question I wonder what is the use of queryOptions?

const queryOptions = options.queryOptions || {};

promise = getItemsForPlayback(serverId, mergePlaybackQueries({
ParentId: firstItem.Id,
Filters: 'IsNotFolder',
Recursive: true,
SortBy: options.shuffle ? 'Random' : 'SortName',
// Only include Photos because we do not handle mixed queues currently
MediaTypes: 'Photo',
Limit: UNLIMITED_ITEMS
}, queryOptions));

@v0idMrK
Copy link
Contributor Author

v0idMrK commented Sep 20, 2023

@dmitrylyzo @v0idMrK A quick Question I wonder what is the use of queryOptions?

const queryOptions = options.queryOptions || {};

promise = getItemsForPlayback(serverId, mergePlaybackQueries({
ParentId: firstItem.Id,
Filters: 'IsNotFolder',
Recursive: true,
SortBy: options.shuffle ? 'Random' : 'SortName',
// Only include Photos because we do not handle mixed queues currently
MediaTypes: 'Photo',
Limit: UNLIMITED_ITEMS
}, queryOptions));

I will try to check today. If I don't have time, then I will go after it tomorrow.

Thank you for the feedback!

Copy link
Contributor

@dmitrylyzo dmitrylyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick Question I wonder what is the use of queryOptions?

It doesn't seem to be passed anywhere in options, but good catch.
In theory it could be used to adjust the base query (only folders are currently using it).

Looking at list.js, the sort options (SortBy and SortOrder) can be placed in queryOptions.
For reference:

query.SortBy = sortValues.sortBy;
query.SortOrder = sortValues.sortOrder;

In the list.js and shortcut.js, we can put sort options as queryOptions.SortBy and queryOptions.SortOrder.
In the playbackmanager.js, we can drop getSortOptions and revert my suggestion (#4786 (comment), most of f922742), and instead merge queryOptions using mergePlaybackQueries.

I made test changes:
test-photo.diff.txt

Btw, SyncPlay duplicates the playback manager. So it should be revised as well.

export function translateItemsForPlayback(apiClient, items, options) {

But it doesn't seem to support Photos, so I am not sure if we should fix it right now.

src/components/shortcuts.js Outdated Show resolved Hide resolved
@grafixeyehero
Copy link
Member

@dmitrylyzo thanks for the clarification. the test change is better in my opinion

Null verification for parentid on shortcuts.js
itemContextMenu is now obeying to sorting
@v0idMrK
Copy link
Contributor Author

v0idMrK commented Sep 20, 2023

@dmitrylyzo @grafixeyehero Hi!

Implemented the suggestions. Anything else please let me know!

Thank you for the feedback 👍

src/components/itemContextMenu.js Outdated Show resolved Hide resolved
src/components/shortcuts.js Outdated Show resolved Hide resolved
src/controllers/list.js Outdated Show resolved Hide resolved
UserSettings added param to function comment
Restoring "Play All" functionality
src/components/itemContextMenu.js Outdated Show resolved Hide resolved
@grafixeyehero
Copy link
Member

@dmitrylyzo it needs your Approval to Thanks👍

@v0idMrK
Copy link
Contributor Author

v0idMrK commented Sep 21, 2023

I agree with the above points.

As soon as I have time I will implement them :)

(Not sure if today or tomorrow)

Thank you all for the feedback!

@v0idMrK
Copy link
Contributor Author

v0idMrK commented Sep 23, 2023

@dmitrylyzo Hey! Just pushed the latest changes 👍

Please let me know if anything else is missing!

Thank you for the feedback.

src/components/playback/playbackmanager.js Outdated Show resolved Hide resolved
src/components/itemContextMenu.js Outdated Show resolved Hide resolved
src/components/itemContextMenu.js Outdated Show resolved Hide resolved
src/components/itemContextMenu.js Outdated Show resolved Hide resolved
@v0idMrK
Copy link
Contributor Author

v0idMrK commented Sep 27, 2023

Sorry for not being able to fix this right away. Been busy lately with stuff in life.

Hopefully next week Im able to finish it :)

@thornbill
Copy link
Member

no worries @v0idMrK whenever you are able to get to it will be fine!

…lists

Revert line change on playbackmanager.js
@v0idMrK
Copy link
Contributor Author

v0idMrK commented Oct 2, 2023

@dmitrylyzo Finally got to it after a while :D

Please let me know if there is anything else missing!

Thank you!

Copy link
Contributor

@dmitrylyzo dmitrylyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost good.

src/scripts/settings/userSettings.js Outdated Show resolved Hide resolved
@jellyfin-bot jellyfin-bot added the merge conflict Conflicts prevent merging label Oct 5, 2023
@jellyfin-bot
Copy link
Collaborator

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@jellyfin-bot jellyfin-bot removed the merge conflict Conflicts prevent merging label Oct 5, 2023
Copy link
Contributor

@dmitrylyzo dmitrylyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Need to update the PR title to suit the changelog.

Found another regression: SortMenu doesn't restore current settings because it expects a PascalCase but receives camelCase.

context.querySelector('.selectSortOrder').value = settings.SortOrder;
context.querySelector('.selectSortBy').value = settings.SortBy;

sortBy: userSettings.getFilter(basekey + '-sortby') || this.getDefaultSortBy(),
sortOrder: userSettings.getFilter(basekey + '-sortorder') === 'Descending' ? 'Descending' : 'Ascending'

This should be fixed in a separate PR. Maybe just use PascalCase for SortBy and SortOrder everywhere (list, shortcuts, etc.).

@thornbill thornbill added the bug Something isn't working label Oct 11, 2023
@jellyfin-bot jellyfin-bot added the merge conflict Conflicts prevent merging label Oct 12, 2023
@jellyfin-bot
Copy link
Collaborator

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@grafixeyehero
Copy link
Member

LGTM Need to update the PR title to suit the changelog.

Found another regression: SortMenu doesn't restore current settings because it expects a PascalCase but receives camelCase.

context.querySelector('.selectSortOrder').value = settings.SortOrder;
context.querySelector('.selectSortBy').value = settings.SortBy;

sortBy: userSettings.getFilter(basekey + '-sortby') || this.getDefaultSortBy(),
sortOrder: userSettings.getFilter(basekey + '-sortorder') === 'Descending' ? 'Descending' : 'Ascending'

This should be fixed in a separate PR. Maybe just use PascalCase for SortBy and SortOrder everywhere (list, shortcuts, etc.).

@dmitrylyzo #4875

@v0idMrK
Copy link
Contributor Author

v0idMrK commented Oct 16, 2023

@thornbill @dmitrylyzo

Hey! Sorry still didnt have time!

When I do I will fix it, just wanted you to know that I didnt forget

@v0idMrK
Copy link
Contributor Author

v0idMrK commented Oct 16, 2023

@thornbill @dmitrylyzo

Could you please check it out when you find the time 😃

Thank you !

@sonarcloud
Copy link

sonarcloud bot commented Oct 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@jellyfin-bot jellyfin-bot removed the merge conflict Conflicts prevent merging label Oct 16, 2023
@jellyfin-bot
Copy link
Collaborator

Cloudflare Pages deployment

Latest commit 298aa01
Status ✅ Deployed!
Preview URL https://36f21002.jellyfin-web.pages.dev
Type 🔀 Preview

View build logs
View bot logs

@thornbill thornbill changed the title Fix #5584 by sending the proper Sort params to the API Add sort options to playback requests Oct 18, 2023
@thornbill thornbill merged commit edd9405 into jellyfin:master Oct 18, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sorting Date added -> descending in photos view shows only thumbnail
5 participants