mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-23 16:56:08 +08:00
9e3c3c14cd
Summary: Move the old bar notifications to the sidebar, and only display one notification at a time using a priority-rating system. Remove all of the old notification infrastructure. Test Plan: Added specs, also reproduced notifications locally Reviewers: bengotow Reviewed By: bengotow Subscribers: juan Differential Revision: https://phab.nylas.com/D3310
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
import {React} from 'nylas-exports';
|
|
import {ipcRenderer, remote, shell} from 'electron';
|
|
import Notification from '../notification';
|
|
|
|
export default class UpdateNotification extends React.Component {
|
|
static displayName = 'UpdateNotification';
|
|
static containerRequired = false;
|
|
|
|
constructor() {
|
|
super();
|
|
this.updater = remote.getGlobal('application').autoUpdateManager
|
|
this.state = this.getStateFromStores();
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.disposable = NylasEnv.onUpdateAvailable(() => {
|
|
this.setState(this.getStateFromStores())
|
|
});
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this.disposable.dispose();
|
|
}
|
|
|
|
getStateFromStores() {
|
|
return {
|
|
updateAvailable: this.updater.getState() === 'update-available',
|
|
version: this.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 <span />
|
|
}
|
|
const version = this.state.version ? `(${this.state.version})` : '';
|
|
return (
|
|
<Notification
|
|
priority="4"
|
|
title={`An update to N1 is available ${version}`}
|
|
subtitle="View changelog"
|
|
subtitleAction={this._onViewChangelog}
|
|
icon="volstead-upgrade.png"
|
|
actions={[{
|
|
label: "Update",
|
|
fn: this._onUpdate,
|
|
}]}
|
|
/>
|
|
)
|
|
}
|
|
}
|