mirror of
https://github.com/zoriya/flood.git
synced 2026-06-03 11:16:36 +00:00
Allow searching & filtering to mutate the data they receive (not their job :)
This commit is contained in:
@@ -1,13 +1,10 @@
|
|||||||
export function filterTorrents(torrentList, torrentListFilterBy) {
|
export function filterTorrents(torrents, filterBy) {
|
||||||
let filteredtorrentList = torrentList;
|
if (filterBy !== 'all') {
|
||||||
|
torrents = torrentList.filter(torrent => {
|
||||||
if (torrentListFilterBy !== 'all') {
|
if (torrent.status.indexOf('is-' + filterBy) > -1) {
|
||||||
filteredtorrentList = torrentList.filter(torrent => {
|
|
||||||
if (torrent.status.indexOf('is-' + torrentListFilterBy) > -1) {
|
|
||||||
return torrent;
|
return torrent;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return torrents;
|
||||||
return filteredtorrentList;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
export function searchTorrents(torrents, searchString) {
|
export function searchTorrents(torrents, searchString) {
|
||||||
let searchedTorrents = torrents;
|
|
||||||
|
|
||||||
if (searchString !== '') {
|
if (searchString !== '') {
|
||||||
let queries = [];
|
let queries = [];
|
||||||
let searchTerms = searchString.replace(/,/g, ' ').split(' ');
|
let searchTerms = searchString.replace(/,/g, ' ').split(' ');
|
||||||
@@ -9,7 +7,7 @@ export function searchTorrents(torrents, searchString) {
|
|||||||
queries.push(new RegExp(searchTerms[i], 'gi'));
|
queries.push(new RegExp(searchTerms[i], 'gi'));
|
||||||
}
|
}
|
||||||
|
|
||||||
searchedTorrents = searchedTorrents.filter(torrent => {
|
torrents = torrents.filter((torrent) => {
|
||||||
for (let i = 0, len = queries.length; i < len; i++) {
|
for (let i = 0, len = queries.length; i < len; i++) {
|
||||||
if (!torrent.name.match(queries[i])) {
|
if (!torrent.name.match(queries[i])) {
|
||||||
return false;
|
return false;
|
||||||
@@ -19,5 +17,5 @@ export function searchTorrents(torrents, searchString) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return searchedTorrents;
|
return torrents;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user