import {React} from 'nylas-exports'; import {ipcRenderer, remote, shell} from 'electron'; import {Notification} from 'nylas-component-kit'; export default class UpdateNotification extends React.Component { static displayName = 'UpdateNotification'; static containerRequired = false; constructor() { super(); this.state = this.getStateFromStores(); } componentDidMount() { this.disposable = NylasEnv.onUpdateAvailable(() => { this.setState(this.getStateFromStores()) }); } componentWillUnmount() { this.disposable.dispose(); } getStateFromStores() { const updater = remote.getGlobal('application').autoUpdateManager; return { updateAvailable: updater.getState() === 'update-available', version: updater.releaseVersion, } } _onUpdate = () => { ipcRenderer.send('command', 'application:install-update') } _onViewChangelog = () => { shell.openExternal('https://github.com/nylas/N1/blob/master/CHANGELOG.md') } render() { if (!this.state.updateAvailable) { return } const version = this.state.version ? `(${this.state.version})` : ''; return ( ) } }