@@ -966,21 +966,17 @@ function getDirection(sort = '', direction = '') {
966966
967967 // Use find() instead of for...in for arrays
968968 const found = Consts .SortDirections .find (option => option .value == sort);
969- direction = found ? found .name : (direction || ' Descending' );
970- console .log (' get direction: ' + direction);
971- return direction;
969+ return found ? found .name : (direction || ' Ascending' );;
972970}
973971
974972function getSorting (sort = ' ' ) {
975973 sort = sort .split (' ,' ).length ? sort .split (' ,' )[0 ] : sort;
976- for (let option in Consts .SortOptions ) {
977- if (Consts .SortOptions [option].value == sort) return Consts .SortOptions [option].name ;
978- }
979- return ;
974+ const found = Consts .SortOptions .find (option => option .value == sort);
975+ return found ? found .name : ' Rank' ;
980976}
981977
982978function updateSorting (sort , list ) {
983- if (typeof list .id == ' string' && list .id .startsWith (' trakt_' )) {
979+ if (list && list . id && typeof list .id == ' string' && list .id .startsWith (' trakt_' )) {
984980 const index = state .genericLists .indexOf (list);
985981 state .genericLists [index].sort = sort .value ;
986982 } else {
@@ -990,11 +986,7 @@ function updateSorting(sort, list) {
990986}
991987
992988function updateSortingDirection (direction , list ) {
993-
994- // Convert ID to string for safe comparison
995- const listId = String (list? .id || ' ' );
996-
997- if (listId .startsWith (' trakt_' )) {
989+ if (list && list .id && typeof list .id == ' string' && list .id .startsWith (' trakt_' )) {
998990 const index = state .genericLists .indexOf (list);
999991 state .genericLists [index].direction = direction .value ;
1000992 } else {
0 commit comments