Skip to content

Commit

Permalink
fix(api): change param hashes to hash (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
Konano authored Sep 9, 2021
1 parent 408facb commit a34a4d2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,7 @@ class Api {
}

public getTorrentTracker(hash: string) {
const params = {
hash,
};

return this.axios.get('/torrents/trackers', {
params,
}).then(Api.handleResponse);
return this.actionTorrent('trackers', hash);
}

public getTorrentPeers(hash: string, rid?: number) {
Expand All @@ -195,7 +189,7 @@ class Api {
}

public editTracker(hash: string, origUrl: string, newUrl: string) {
return this.actionTorrents('editTracker', [hash], { origUrl, newUrl });
return this.actionTorrent('editTracker', hash, { origUrl, newUrl });
}

public setTorrentLocation(hashes: string[], location: string) {
Expand Down Expand Up @@ -351,6 +345,15 @@ class Api {
return this.axios.post('/search/enablePlugin', body).then(Api.handleResponse);
}

private actionTorrent(action: string, hash: string, extra?: any) {
const params: any = {
hash,
...extra,
};
const data = new URLSearchParams(params);
return this.axios.post(`/torrents/${action}`, data).then(Api.handleResponse);
}

private actionTorrents(action: string, hashes: string[], extra?: any) {
const params: any = {
hashes: hashes.join('|'),
Expand Down

0 comments on commit a34a4d2

Please sign in to comment.