1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #1237 from DesertCookie/sorted-media-sources

Sort multi-version movie dropdown menu
This commit is contained in:
Bill Thornton 2020-11-25 15:07:25 -05:00 committed by GitHub
commit 7ec3724db6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -36,6 +36,7 @@
- [MrTimscampi](https://github.com/MrTimscampi)
- [ConfusedPolarBear](https://github.com/ConfusedPolarBear)
- [Sarab Singh](https://github.com/sarab97)
- [DesertCookie](https://github.com/desertcookie)
- [GuilhermeHideki](https://github.com/GuilhermeHideki)
- [Andrei Oanca](https://github.com/OancaAndrei)
- [Cromefire_](https://github.com/cromefire)

View file

@ -171,7 +171,30 @@ function renderTrackSelections(page, instance, item, forceReload) {
return;
}
const mediaSources = item.MediaSources;
let mediaSources = item.MediaSources;
const resolutionNames = [];
const sourceNames = [];
mediaSources.forEach(function (v) {
(v.Name.endsWith('p') || v.Name.endsWith('i')) && !Number.isNaN(parseInt(v.Name, 10)) ? resolutionNames.push(v) : sourceNames.push(v);
});
resolutionNames.sort((a, b) => parseInt(b.Name, 10) - parseInt(a.Name, 10));
sourceNames.sort(function(a, b) {
const nameA = a.Name.toUpperCase();
const nameB = b.Name.toUpperCase();
if (nameA < nameB) {
return -1;
} else if (nameA > nameB) {
return 1;
}
return 0;
});
mediaSources = [];
resolutionNames.forEach(v => mediaSources.push(v));
sourceNames.forEach(v => mediaSources.push(v));
instance._currentPlaybackMediaSources = mediaSources;
page.querySelector('.trackSelections').classList.remove('hide');