Fix remove torrent button

This commit is contained in:
Grégoire Delattre 2017-08-15 14:37:26 +02:00
parent 380c9c453a
commit 2f31f81d26
3 changed files with 5 additions and 14 deletions

View File

@ -19,7 +19,7 @@ export function removeTorrent(id) {
"REMOVE_TORRENT",
configureAxios().delete(`/torrents/${id}`),
[
fetchTorrents(),
() => fetchTorrents(),
]
)
}

View File

@ -3,8 +3,6 @@ import { connect } from "react-redux"
import { bindActionCreators } from "redux"
import { addTorrent, removeTorrent } from "../../actions/torrents"
import { OverlayTrigger, Tooltip } from "react-bootstrap"
function mapStateToProps(state) {
return { torrents: state.torrentStore.get("torrents") };
}
@ -116,7 +114,6 @@ class Torrent extends React.PureComponent {
this.props.removeTorrent(this.props.data.getIn(["additional_infos", "id"]));
}
render() {
const id = this.props.data.getIn(["additional_infos", "id"]);
const done = this.props.data.get("is_finished");
var progressStyle = "progress-bar progress-bar-info active";
if (done) {
@ -128,8 +125,6 @@ class Torrent extends React.PureComponent {
percentDone = Number(percentDone).toFixed(1) + "%";
}
const tooltip = (<Tooltip id={id}>Remove this torrent</Tooltip>);
// Pretty sizes
const downloadedSize = prettySize(this.props.data.get("downloaded_size"));
const totalSize = prettySize(this.props.data.get("total_size"));
@ -138,11 +133,7 @@ class Torrent extends React.PureComponent {
<div className="panel panel-default">
<div className="panel-heading">
{this.props.data.get("name")}
<span className="clickable pull-right" onClick={this.handleClick}>
<OverlayTrigger placement="top" overlay={tooltip}>
<span className="fa fa-trash"></span>
</OverlayTrigger>
</span>
<span className="fa fa-trash clickable pull-right" onClick={this.handleClick}></span>
</div>
<div className="panel-body">
{started &&

View File

@ -30,12 +30,12 @@ export function request(eventPrefix, promise, callbackEvents = null, mainPayload
})
promise
.then(response => {
if (response.data.status === "error")
if (response.status === "error")
{
dispatch({
type: "ADD_ALERT_ERROR",
payload: {
message: response.data.message,
message: response.message,
main: mainPayload,
}
});
@ -50,7 +50,7 @@ export function request(eventPrefix, promise, callbackEvents = null, mainPayload
})
if (callbackEvents) {
for (let event of callbackEvents) {
if (typeof event === 'function') {
if (typeof event === "function") {
event = event();
}
dispatch(event);