import React from 'react'; import PropTypes from 'prop-types'; import { DefaultClientHelper, SystemStartService } from 'mailspring-exports'; import { shell } from 'electron'; import ConfigSchemaItem from './config-schema-item'; class DefaultMailClientItem extends React.Component { constructor() { super(); this._helper = new DefaultClientHelper(); if (this._helper.available()) { this.state = { defaultClient: false }; this._helper.isRegisteredForURLScheme('mailto', registered => { if (this._mounted) this.setState({ defaultClient: registered }); }); } else { this.state = { defaultClient: 'unknown' }; } } componentDidMount() { this._mounted = true; } componentWillUnmount() { this._mounted = false; } toggleDefaultMailClient = event => { if (this.state.defaultClient) { this.setState({ defaultClient: false }); this._helper.resetURLScheme('mailto'); } else { this.setState({ defaultClient: true }); this._helper.registerForURLScheme('mailto'); } event.target.blur(); }; render() { if (this.state.defaultClient === 'unknown') { return (
shell.openExternal('https://foundry376.zendesk.com/hc/en-us/articles/115002281851')} > Use Mailspring as default mail client
); } return (
); } } class LaunchSystemStartItem extends React.Component { constructor() { super(); this.state = { available: false, launchOnStart: false, }; this._service = new SystemStartService(); } componentDidMount() { this._mounted = true; this._service.checkAvailability().then(available => { if (this._mounted) { this.setState({ available }); } if (!available || !this._mounted) return; this._service.doesLaunchOnSystemStart().then(launchOnStart => { if (this._mounted) { this.setState({ launchOnStart }); } }); }); } componentWillUnmount() { this._mounted = false; } _toggleLaunchOnStart = event => { if (this.state.launchOnStart) { this.setState({ launchOnStart: false }); this._service.dontLaunchOnSystemStart(); } else { this.setState({ launchOnStart: true }); this._service.configureToLaunchOnSystemStart(); } event.target.blur(); }; render() { if (!this.state.available) return false; return (
); } } const WorkspaceSection = props => { return (
"Launch on system start" only works in XDG-compliant desktop environments. To enable the Mailspring icon in the system tray, you may need to install libappindicator1. (i.e., sudo apt-get install libappindicator1)
); }; WorkspaceSection.propTypes = { config: PropTypes.object, configSchema: PropTypes.object, }; export default WorkspaceSection;