mirror of
https://github.com/Radarr/Radarr.git
synced 2024-07-15 00:57:36 +02:00
New: Sort movies by release dates
This commit is contained in:
parent
32722eb704
commit
15bb9139d1
@ -100,6 +100,15 @@ function MovieIndexSortMenu(props: MovieIndexSortMenuProps) {
|
|||||||
{translate('DigitalRelease')}
|
{translate('DigitalRelease')}
|
||||||
</SortMenuItem>
|
</SortMenuItem>
|
||||||
|
|
||||||
|
<SortMenuItem
|
||||||
|
name="releaseDate"
|
||||||
|
sortKey={sortKey}
|
||||||
|
sortDirection={sortDirection}
|
||||||
|
onPress={onSortSelect}
|
||||||
|
>
|
||||||
|
{translate('ReleaseDates')}
|
||||||
|
</SortMenuItem>
|
||||||
|
|
||||||
<SortMenuItem
|
<SortMenuItem
|
||||||
name="tmdbRating"
|
name="tmdbRating"
|
||||||
sortKey={sortKey}
|
sortKey={sortKey}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import moment from 'moment';
|
||||||
import { createAction } from 'redux-actions';
|
import { createAction } from 'redux-actions';
|
||||||
import { batchActions } from 'redux-batched-actions';
|
import { batchActions } from 'redux-batched-actions';
|
||||||
import { filterTypePredicates, filterTypes, sortDirections } from 'Helpers/Props';
|
import { filterTypePredicates, filterTypes, sortDirections } from 'Helpers/Props';
|
||||||
@ -240,16 +241,55 @@ export const sortPredicates = {
|
|||||||
return item.year || undefined;
|
return item.year || undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
inCinemas: function(item) {
|
inCinemas: function(item, direction) {
|
||||||
return item.inCinemas || '';
|
if (item.inCinemas) {
|
||||||
|
return moment(item.inCinemas).unix();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction === sortDirections.DESCENDING) {
|
||||||
|
return -1 * Number.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Number.MAX_VALUE;
|
||||||
},
|
},
|
||||||
|
|
||||||
physicalRelease: function(item) {
|
physicalRelease: function(item, direction) {
|
||||||
return item.physicalRelease || '';
|
if (item.physicalRelease) {
|
||||||
|
return moment(item.physicalRelease).unix();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction === sortDirections.DESCENDING) {
|
||||||
|
return -1 * Number.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Number.MAX_VALUE;
|
||||||
},
|
},
|
||||||
|
|
||||||
digitalRelease: function(item) {
|
digitalRelease: function(item, direction) {
|
||||||
return item.digitalRelease || '';
|
if (item.digitalRelease) {
|
||||||
|
return moment(item.digitalRelease).unix();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction === sortDirections.DESCENDING) {
|
||||||
|
return -1 * Number.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Number.MAX_VALUE;
|
||||||
|
},
|
||||||
|
|
||||||
|
releaseDate: function(item, direction) {
|
||||||
|
const { inCinemas, digitalRelease, physicalRelease } = item;
|
||||||
|
const releaseDate = digitalRelease || physicalRelease || inCinemas;
|
||||||
|
|
||||||
|
if (releaseDate) {
|
||||||
|
return moment(releaseDate).unix();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction === sortDirections.DESCENDING) {
|
||||||
|
return -1 * Number.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Number.MAX_VALUE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user