35 lines
797 B
JavaScript
35 lines
797 B
JavaScript
import { configureAxios, request } from "../requests";
|
|
|
|
import { addAlertOk } from "./alerts";
|
|
|
|
export function addTorrent(torrent) {
|
|
return request("ADD_TORRENT", configureAxios().post("/torrents", torrent), [
|
|
addAlertOk("Torrent added"),
|
|
]);
|
|
}
|
|
|
|
export function removeTorrent(id) {
|
|
return request("REMOVE_TORRENT", configureAxios().delete(`/torrents/${id}`), [
|
|
() => fetchTorrents(),
|
|
]);
|
|
}
|
|
|
|
export function fetchTorrents() {
|
|
return request("TORRENTS_FETCH", configureAxios().get("/torrents"));
|
|
}
|
|
|
|
export function searchTorrents(url) {
|
|
return request("TORRENTS_SEARCH", configureAxios().get(url));
|
|
}
|
|
|
|
export function setFetchedTorrents(torrents) {
|
|
return {
|
|
type: "TORRENTS_FETCH_FULFILLED",
|
|
payload: {
|
|
response: {
|
|
data: torrents,
|
|
},
|
|
},
|
|
};
|
|
}
|