Fix Recording List Column sorting in Google chrome

This commit is contained in:
Justin Stephenson 2019-08-29 16:20:30 -04:00
parent 849fcd2d49
commit ac612470bd

View file

@ -476,7 +476,7 @@ class RecordingList extends React.Component {
} else { } else {
this.setState({ this.setState({
sorting_field: event.currentTarget.id, sorting_field: event.currentTarget.id,
sorting_asc: 'asc' sorting_asc: true,
}); });
} }
} }
@ -485,17 +485,20 @@ class RecordingList extends React.Component {
let field = this.state.sorting_field; let field = this.state.sorting_field;
let asc = this.state.sorting_asc; let asc = this.state.sorting_asc;
let list = this.props.list.slice(); let list = this.props.list.slice();
let isNumeric;
if (this.state.sorting_field != null) { if (field === "start" || field === "end" || field === "duration") {
if (asc) { isNumeric = true;
list.sort(function(a, b) {
return a[field] > b[field];
});
} else {
list.sort(function(a, b) {
return a[field] < b[field];
});
} }
if (isNumeric) {
list.sort((a, b) => a[field] - b[field]);
} else {
list.sort((a, b) => (a[field] > b[field]) ? 1 : -1);
}
if (!asc) {
list.reverse();
} }
return list; return list;