Find same named torrent when set category

This commit is contained in:
CzBiX
2019-09-14 21:46:00 +08:00
parent 2412214020
commit bcd8ed3389
4 changed files with 150 additions and 24 deletions

View File

@@ -66,3 +66,24 @@ export function codeToFlag(code: string) {
}
export const isWindows = navigator.userAgent.includes('Windows');
export function getSameNamedTorrents(allTorrents: Array<any>, torrents: Array<any>) {
const hashes = _.map(torrents, (t) => t.hash);
const result = [];
for (const t1 of torrents) {
for (const t2 of allTorrents) {
if (hashes.includes(t2.hash)) {
continue;
}
if (t1.name != t2.name) {
continue;
}
result.push(t2);
hashes.push(t2);
}
}
return result;
};