mirror of
https://github.com/zoriya/flood.git
synced 2026-05-22 15:11:39 +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) {
|
||||
let filteredtorrentList = torrentList;
|
||||
|
||||
if (torrentListFilterBy !== 'all') {
|
||||
filteredtorrentList = torrentList.filter(torrent => {
|
||||
if (torrent.status.indexOf('is-' + torrentListFilterBy) > -1) {
|
||||
export function filterTorrents(torrents, filterBy) {
|
||||
if (filterBy !== 'all') {
|
||||
torrents = torrentList.filter(torrent => {
|
||||
if (torrent.status.indexOf('is-' + filterBy) > -1) {
|
||||
return torrent;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return filteredtorrentList;
|
||||
return torrents;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
export function searchTorrents(torrents, searchString) {
|
||||
let searchedTorrents = torrents;
|
||||
|
||||
if (searchString !== '') {
|
||||
let queries = [];
|
||||
let searchTerms = searchString.replace(/,/g, ' ').split(' ');
|
||||
@@ -9,7 +7,7 @@ export function searchTorrents(torrents, searchString) {
|
||||
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++) {
|
||||
if (!torrent.name.match(queries[i])) {
|
||||
return false;
|
||||
@@ -19,5 +17,5 @@ export function searchTorrents(torrents, searchString) {
|
||||
});
|
||||
}
|
||||
|
||||
return searchedTorrents;
|
||||
return torrents;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user