Fix sorting bug

This commit is contained in:
John Furrow
2016-01-07 18:26:04 -08:00
parent 23ba989d81
commit 6819f759a3
2 changed files with 14 additions and 15 deletions
+12 -12
View File
@@ -80,28 +80,28 @@ class TorrentStoreClass extends BaseStore {
}
setTorrents(torrents) {
let torrentsSort = TorrentFilterStore.getTorrentsSort();
this.torrents = sortTorrents(
Object.assign([], torrents),
TorrentFilterStore.getTorrentsSort()
{direction: torrentsSort.direction, property: torrentsSort.value}
);
let statusFilter = TorrentFilterStore.getStatusFilter();
let searchFilter = TorrentFilterStore.getSearchFilter();
if (statusFilter || searchFilter) {
let filteredTorrents = Object.assign([], this.torrents);
let filteredTorrents = Object.assign([], this.torrents);
if (statusFilter && statusFilter !== 'all') {
filteredTorrents = filterTorrents(filteredTorrents, statusFilter);
}
if (searchFilter && searchFilter !== '') {
filteredTorrents = searchTorrents(filteredTorrents, searchFilter);
}
this.filteredTorrents = filteredTorrents;
if (statusFilter && statusFilter !== 'all') {
filteredTorrents = filterTorrents(filteredTorrents, statusFilter);
}
if (searchFilter && searchFilter !== '') {
filteredTorrents = searchTorrents(filteredTorrents, searchFilter);
}
this.filteredTorrents = filteredTorrents;
this.emit(EventTypes.CLIENT_TORRENTS_REQUEST_SUCCESS);
}
+2 -3
View File
@@ -2,9 +2,8 @@ export function sortTorrents(torrents, sortBy) {
if (torrents.length) {
let direction = sortBy.direction;
let property = sortBy.property;
let sortedTorrents = Object.assign([], torrents);
sortedTorrents.sort(function(a, b) {
torrents.sort(function(a, b) {
let valA = a[property];
let valB = b[property];
@@ -49,7 +48,7 @@ export function sortTorrents(torrents, sortBy) {
return 0;
});
return sortedTorrents;
return torrents;
} else {
return torrents;
}