mirror of
https://github.com/zoriya/flood.git
synced 2026-05-31 10:22:44 +00:00
Fix sorting bug
This commit is contained in:
@@ -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,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user