mirror of
https://github.com/zoriya/flood.git
synced 2026-05-31 18:25:25 +00:00
Add tracker filter an abstract components along the way
This commit is contained in:
@@ -1,14 +1,24 @@
|
||||
import propsMaps from '../../../../shared/constants/propsMap';
|
||||
|
||||
export function filterTorrents(torrentList, filterBy) {
|
||||
export function filterTorrents(torrentList, opts) {
|
||||
let statusMap = propsMaps.clientStatus;
|
||||
let {type, filter} = opts;
|
||||
|
||||
if (filterBy !== 'all') {
|
||||
torrentList = torrentList.filter((torrent) => {
|
||||
if (torrent.status.indexOf(statusMap[filterBy]) > -1) {
|
||||
return torrent;
|
||||
}
|
||||
});
|
||||
if (filter !== 'all') {
|
||||
if (type === 'status') {
|
||||
let statusFilter = statusMap[filter];
|
||||
return torrentList.filter(function(torrent) {
|
||||
if (torrent.status.indexOf(statusFilter) > -1) {
|
||||
return torrent;
|
||||
}
|
||||
});
|
||||
} else if (type === 'tracker') {
|
||||
return torrentList.filter(function(torrent) {
|
||||
if (torrent.trackers.indexOf(filter) > -1) {
|
||||
return torrent;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return torrentList;
|
||||
|
||||
Reference in New Issue
Block a user