Fix remove torrent button
This commit is contained in:
parent
380c9c453a
commit
2f31f81d26
@ -19,7 +19,7 @@ export function removeTorrent(id) {
|
|||||||
"REMOVE_TORRENT",
|
"REMOVE_TORRENT",
|
||||||
configureAxios().delete(`/torrents/${id}`),
|
configureAxios().delete(`/torrents/${id}`),
|
||||||
[
|
[
|
||||||
fetchTorrents(),
|
() => fetchTorrents(),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@ import { connect } from "react-redux"
|
|||||||
import { bindActionCreators } from "redux"
|
import { bindActionCreators } from "redux"
|
||||||
import { addTorrent, removeTorrent } from "../../actions/torrents"
|
import { addTorrent, removeTorrent } from "../../actions/torrents"
|
||||||
|
|
||||||
import { OverlayTrigger, Tooltip } from "react-bootstrap"
|
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return { torrents: state.torrentStore.get("torrents") };
|
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"]));
|
this.props.removeTorrent(this.props.data.getIn(["additional_infos", "id"]));
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const id = this.props.data.getIn(["additional_infos", "id"]);
|
|
||||||
const done = this.props.data.get("is_finished");
|
const done = this.props.data.get("is_finished");
|
||||||
var progressStyle = "progress-bar progress-bar-info active";
|
var progressStyle = "progress-bar progress-bar-info active";
|
||||||
if (done) {
|
if (done) {
|
||||||
@ -128,8 +125,6 @@ class Torrent extends React.PureComponent {
|
|||||||
percentDone = Number(percentDone).toFixed(1) + "%";
|
percentDone = Number(percentDone).toFixed(1) + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
const tooltip = (<Tooltip id={id}>Remove this torrent</Tooltip>);
|
|
||||||
|
|
||||||
// Pretty sizes
|
// Pretty sizes
|
||||||
const downloadedSize = prettySize(this.props.data.get("downloaded_size"));
|
const downloadedSize = prettySize(this.props.data.get("downloaded_size"));
|
||||||
const totalSize = prettySize(this.props.data.get("total_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 panel-default">
|
||||||
<div className="panel-heading">
|
<div className="panel-heading">
|
||||||
{this.props.data.get("name")}
|
{this.props.data.get("name")}
|
||||||
<span className="clickable pull-right" onClick={this.handleClick}>
|
<span className="fa fa-trash clickable pull-right" onClick={this.handleClick}></span>
|
||||||
<OverlayTrigger placement="top" overlay={tooltip}>
|
|
||||||
<span className="fa fa-trash"></span>
|
|
||||||
</OverlayTrigger>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="panel-body">
|
<div className="panel-body">
|
||||||
{started &&
|
{started &&
|
||||||
|
@ -30,12 +30,12 @@ export function request(eventPrefix, promise, callbackEvents = null, mainPayload
|
|||||||
})
|
})
|
||||||
promise
|
promise
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.status === "error")
|
if (response.status === "error")
|
||||||
{
|
{
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "ADD_ALERT_ERROR",
|
type: "ADD_ALERT_ERROR",
|
||||||
payload: {
|
payload: {
|
||||||
message: response.data.message,
|
message: response.message,
|
||||||
main: mainPayload,
|
main: mainPayload,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -50,7 +50,7 @@ export function request(eventPrefix, promise, callbackEvents = null, mainPayload
|
|||||||
})
|
})
|
||||||
if (callbackEvents) {
|
if (callbackEvents) {
|
||||||
for (let event of callbackEvents) {
|
for (let event of callbackEvents) {
|
||||||
if (typeof event === 'function') {
|
if (typeof event === "function") {
|
||||||
event = event();
|
event = event();
|
||||||
}
|
}
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user