diff --git a/src/components/listview/listview.js b/src/components/listview/listview.js index ee75656367..1cbbc3a8ec 100644 --- a/src/components/listview/listview.js +++ b/src/components/listview/listview.js @@ -42,6 +42,9 @@ import ServerConnections from '../ServerConnections'; return name.toUpperCase(); } + if (sortBy.indexOf('random') === 0) { + return Math.random(item.Random); + } if (sortBy.indexOf('officialrating') === 0) { return item.OfficialRating || globalize.translate('Unrated'); } diff --git a/src/controllers/list.js b/src/controllers/list.js index b880502828..67f781f353 100644 --- a/src/controllers/list.js +++ b/src/controllers/list.js @@ -996,6 +996,12 @@ class ItemsView { sortBy.push(option); } + option = this.getRandomSortOption(); + + if (option) { + sortBy.push(option); + } + option = this.getCommunityRatingSortOption(); if (option) { @@ -1064,6 +1070,17 @@ class ItemsView { }; } + getPlayCountSortOption() { + if (this.params.type === 'Programs') { + return null; + } + + return { + name: globalize.translate('Random'), + value: 'Random,SortName' + }; + } + getPlayCountSortOption() { if (this.params.type === 'Programs') { return null; diff --git a/src/controllers/movies/movies.js b/src/controllers/movies/movies.js index e8137fd764..5990eb7e58 100644 --- a/src/controllers/movies/movies.js +++ b/src/controllers/movies/movies.js @@ -197,6 +197,9 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer'; items: [{ name: globalize.translate('Name'), id: 'SortName,ProductionYear' + }, { + name: globalize.translate('Random'), + id: 'Random' }, { name: globalize.translate('OptionImdbRating'), id: 'CommunityRating,SortName,ProductionYear' diff --git a/src/controllers/shows/tvshows.js b/src/controllers/shows/tvshows.js index 02a4a4543f..dde7a0bc31 100644 --- a/src/controllers/shows/tvshows.js +++ b/src/controllers/shows/tvshows.js @@ -252,6 +252,9 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer'; items: [{ name: globalize.translate('Name'), id: 'SortName' + }, { + name: globalize.translate('Random'), + id: 'Random' }, { name: globalize.translate('OptionImdbRating'), id: 'CommunityRating,SortName'