From 178cef0d9138e91aa4f0c47ac3c7e6ed6c5cfb05 Mon Sep 17 00:00:00 2001 From: Danny Michel Date: Thu, 12 May 2022 13:15:15 -0400 Subject: [PATCH 1/3] Add random sorting Added random sorting to tv shows and movies lists --- src/components/listview/listview.js | 3 +++ src/controllers/list.js | 17 +++++++++++++++++ src/controllers/movies/movies.js | 3 +++ src/controllers/shows/tvshows.js | 3 +++ 4 files changed, 26 insertions(+) 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' From 8a2e2af2eb128ad6fc697315782449e8ab78c819 Mon Sep 17 00:00:00 2001 From: Danny Michel Date: Thu, 12 May 2022 17:43:28 -0400 Subject: [PATCH 2/3] Requested changes Requested changes https://github.com/jellyfin/jellyfin-web/pull/3631#discussion_r871799701 https://github.com/jellyfin/jellyfin-web/pull/3631#discussion_r871800253 https://github.com/jellyfin/jellyfin-web/pull/3631#discussion_r871800701 --- src/components/listview/listview.js | 3 --- src/controllers/list.js | 11 ----------- src/controllers/movies/movies.js | 2 +- src/controllers/shows/tvshows.js | 2 +- 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/components/listview/listview.js b/src/components/listview/listview.js index 1cbbc3a8ec..ee75656367 100644 --- a/src/components/listview/listview.js +++ b/src/components/listview/listview.js @@ -42,9 +42,6 @@ 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 67f781f353..c5ff9bdb34 100644 --- a/src/controllers/list.js +++ b/src/controllers/list.js @@ -1070,17 +1070,6 @@ 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 5990eb7e58..0dbf314cc4 100644 --- a/src/controllers/movies/movies.js +++ b/src/controllers/movies/movies.js @@ -198,7 +198,7 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer'; name: globalize.translate('Name'), id: 'SortName,ProductionYear' }, { - name: globalize.translate('Random'), + name: globalize.translate('OptionRandom'), id: 'Random' }, { name: globalize.translate('OptionImdbRating'), diff --git a/src/controllers/shows/tvshows.js b/src/controllers/shows/tvshows.js index dde7a0bc31..ba18ecec7f 100644 --- a/src/controllers/shows/tvshows.js +++ b/src/controllers/shows/tvshows.js @@ -253,7 +253,7 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer'; name: globalize.translate('Name'), id: 'SortName' }, { - name: globalize.translate('Random'), + name: globalize.translate('OptionRandom'), id: 'Random' }, { name: globalize.translate('OptionImdbRating'), From b4157adfd30361dc8a440bd6bf7337cea4570982 Mon Sep 17 00:00:00 2001 From: Danny Michel Date: Thu, 12 May 2022 23:31:07 -0400 Subject: [PATCH 3/3] Requested change Requested change --- src/controllers/list.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/controllers/list.js b/src/controllers/list.js index c5ff9bdb34..b880502828 100644 --- a/src/controllers/list.js +++ b/src/controllers/list.js @@ -996,12 +996,6 @@ class ItemsView { sortBy.push(option); } - option = this.getRandomSortOption(); - - if (option) { - sortBy.push(option); - } - option = this.getCommunityRatingSortOption(); if (option) {