Implement {Pause,Resume} all buttons

master
Drew DeVault 2017-08-25 19:41:34 -04:00
parent be9e6a621d
commit 06561f9580
4 changed files with 23 additions and 12 deletions

View File

@ -7,14 +7,6 @@ export const SUBTRACT = 'SUBTRACT';
export const EXCLUSIVE = 'EXCLUSIVE';
export const NONE = 'NONE';
Set.prototype.difference = function(set) {
var diff = new Set(this);
for (var v of set) {
diff.delete(v);
}
return diff;
}
export default function selectTorrent(id, action) {
return (dispatch, getState) => {
const previous = new Set(getState().selection);

View File

@ -4,6 +4,7 @@ import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'react-router-redux';
import 'preact/devtools';
import './polyfills';
import store, { history } from './store';
import scss from '../scss/main.scss';

10
src/polyfills.js 100644
View File

@ -0,0 +1,10 @@
Set.prototype.difference = function(set) {
var diff = new Set(this);
for (var v of set) {
diff.delete(v);
}
return diff;
}
// Required by ES6 spec
export const _ = null;

View File

@ -15,8 +15,6 @@ import {
import ws_send from '../socket';
import selectTorrent, { UNION, NONE } from '../actions/selection';
// TODO: fix navigating directly to torrent pages
function File({ file }) {
// TODO: show progress bar
// TODO: edit priority
@ -168,8 +166,18 @@ class TorrentDetails extends Component {
<div>
<h3>{selection.length} torrents</h3>
<ButtonGroup>
<button className="btn btn-default btn-sm">Pause all</button>
<button className="btn btn-default btn-sm">Resume all</button>
<button
className="btn btn-default btn-sm"
onClick={() => {
selection.forEach(id => ws_send("PAUSE_TORRENT", { id }));
}}
>Pause all</button>
<button
className="btn btn-default btn-sm"
onClick={() => {
selection.forEach(id => ws_send("RESUME_TORRENT", { id }));
}}
>Resume all</button>
<ButtonDropdown
isOpen={this.state.removeDropdown}
toggle={() => this.setState({ removeDropdown: !this.state.removeDropdown })}