Sort movies by year by default

This commit is contained in:
Grégoire Delattre 2017-01-29 19:28:42 +01:00
parent 80dba4e4d3
commit 42bc4bf957

View File

@ -18,6 +18,8 @@ export default function movieStore(state = defaultState, action) {
let selectedImdbId = "";
// Select the first movie
if (action.payload.data.length > 0) {
// Sort by year
action.payload.data.sort((a,b) => b.year - a.year);
selectedImdbId = action.payload.data[0].imdb_id;
}
return Object.assign({}, state, {