canape/frontend/js/actions/torrents.js
Grégoire Delattre bcadc48d5a Launch prettier with the --fix option
They've changed their default settings, this changes a lot of stuff in
our code base.
2020-04-01 17:55:34 +02:00

39 lines
816 B
JavaScript

import { configureAxios, request } from "../requests";
import { addAlertOk } from "./alerts";
export function addTorrent(url) {
return request(
"ADD_TORRENT",
configureAxios().post("/torrents", {
url: url,
}),
[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,
},
},
};
}