Fixed: Sort qualities by name within group when sorting by status

Relates to #4189, Optimal end state would be to sort by quality weight within group, however that is not currently passed from API with the quality object.
pull/2/head
Qstick 5 years ago
parent 64e9e48217
commit 7173c5c737

@ -3,6 +3,7 @@ import { createAction } from 'redux-actions';
// import { batchActions } from 'redux-batched-actions'; // import { batchActions } from 'redux-batched-actions';
import createAjaxRequest from 'Utilities/createAjaxRequest'; import createAjaxRequest from 'Utilities/createAjaxRequest';
import dateFilterPredicate from 'Utilities/Date/dateFilterPredicate'; import dateFilterPredicate from 'Utilities/Date/dateFilterPredicate';
import padNumber from 'Utilities/Number/padNumber';
import { filterTypePredicates, filterTypes, sortDirections } from 'Helpers/Props'; import { filterTypePredicates, filterTypes, sortDirections } from 'Helpers/Props';
import { createThunk, handleThunks } from 'Store/thunks'; import { createThunk, handleThunks } from 'Store/thunks';
import createSetSettingValueReducer from './Creators/Reducers/createSetSettingValueReducer'; import createSetSettingValueReducer from './Creators/Reducers/createSetSettingValueReducer';
@ -163,9 +164,18 @@ export const sortPredicates = {
movieStatus: function(item) { movieStatus: function(item) {
let result = 0; let result = 0;
let qualityName = '';
const hasMovieFile = !!item.movieFile; const hasMovieFile = !!item.movieFile;
if (item.isAvailable && item.inCinemas) {
result++;
}
if (item.monitored) {
result += 2;
}
if (hasMovieFile) { if (hasMovieFile) {
// TODO: Consider Quality Weight for Sorting within status of hasMovie // TODO: Consider Quality Weight for Sorting within status of hasMovie
if (item.movieFile.qualityCutoffNotMet) { if (item.movieFile.qualityCutoffNotMet) {
@ -173,17 +183,10 @@ export const sortPredicates = {
} else { } else {
result += 8; result += 8;
} }
qualityName = item.movieFile.quality.quality.name;
} }
if (item.isAvailable) { return padNumber(result.toString(), 2) + qualityName;
result++;
}
if (item.monitored) {
result += 2;
}
return result;
} }
}; };

Loading…
Cancel
Save