mirror of
https://github.com/zoriya/flood.git
synced 2025-12-20 06:05:15 +00:00
Save settings more reasonably
This commit is contained in:
@@ -2,8 +2,30 @@ import React from 'react';
|
||||
|
||||
import LoadingIndicatorDots from '../icons/LoadingIndicatorDots';
|
||||
import ModalActions from './ModalActions';
|
||||
import SettingsStore from '../../stores/SettingsStore';
|
||||
|
||||
const METHODS_TO_BIND = ['handleStartTorrentsToggle'];
|
||||
|
||||
export default class AddTorrents extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.state = {
|
||||
startTorrentsOnLoad: true
|
||||
};
|
||||
|
||||
METHODS_TO_BIND.forEach((method) => {
|
||||
this[method] = this[method].bind(this);
|
||||
});
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
let startTorrentsOnLoad = SettingsStore.getSettings('startTorrentsOnLoad');
|
||||
if (startTorrentsOnLoad !== true) {
|
||||
this.setState({startTorrentsOnLoad: false});
|
||||
}
|
||||
}
|
||||
|
||||
getActions() {
|
||||
let icon = null;
|
||||
let primaryButtonText = 'Add Torrent';
|
||||
@@ -15,8 +37,8 @@ export default class AddTorrents extends React.Component {
|
||||
|
||||
return [
|
||||
{
|
||||
checked: true,
|
||||
clickHandler: this.props.onStartTorrentsToggle,
|
||||
checked: this.state.startTorrentsOnLoad,
|
||||
clickHandler: this.handleStartTorrentsToggle,
|
||||
content: 'Start Torrent',
|
||||
triggerDismiss: false,
|
||||
type: 'checkbox'
|
||||
@@ -42,6 +64,13 @@ export default class AddTorrents extends React.Component {
|
||||
];
|
||||
}
|
||||
|
||||
handleStartTorrentsToggle(value) {
|
||||
SettingsStore.saveSettings({id: 'startTorrentsOnLoad', data: value});
|
||||
if (!!this.props.onStartTorrentsToggle) {
|
||||
this.props.onStartTorrentsToggle(value);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<ModalActions actions={this.getActions()} dismiss={this.props.dismiss} />
|
||||
|
||||
Reference in New Issue
Block a user