mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-12 17:26:17 +00:00
Create confirm download dialog
This commit is contained in:
committed by
Junyoung Choi
parent
18d65d999a
commit
553832bdfa
@@ -12,6 +12,7 @@ import DevTools from './DevTools'
|
||||
require('./lib/ipcClient')
|
||||
require('../lib/customMeta')
|
||||
import i18n from 'browser/lib/i18n'
|
||||
import ConfigManager from './lib/ConfigManager'
|
||||
|
||||
const electron = require('electron')
|
||||
|
||||
@@ -107,6 +108,21 @@ function updateApp() {
|
||||
}
|
||||
}
|
||||
|
||||
function downloadUpdate() {
|
||||
const index = dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||
type: 'warning',
|
||||
message: i18n.__('Update Boostnote'),
|
||||
detail: i18n.__('New Boostnote is ready to be downloaded.'),
|
||||
buttons: [i18n.__('Download now'), i18n.__('Ignore updates')]
|
||||
})
|
||||
|
||||
if (index === 0) {
|
||||
ipcRenderer.send('update-app-confirm')
|
||||
} else if (index === 1) {
|
||||
ConfigManager.set({ autoUpdateEnabled: false })
|
||||
}
|
||||
}
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<ConnectedRouter history={history}>
|
||||
@@ -147,9 +163,7 @@ ReactDOM.render(
|
||||
})
|
||||
|
||||
ipcRenderer.on('update-found', function() {
|
||||
notify('Update found!', {
|
||||
body: 'Preparing to update...'
|
||||
})
|
||||
downloadUpdate()
|
||||
})
|
||||
|
||||
ipcRenderer.on('update-not-found', function(_, msg) {
|
||||
|
||||
@@ -23,13 +23,22 @@ class InfoTab extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { autoUpdateEnabled, amaEnabled } = ConfigManager.get()
|
||||
|
||||
this.setState({ config: { autoUpdateEnabled, amaEnabled } })
|
||||
}
|
||||
|
||||
handleLinkClick(e) {
|
||||
shell.openExternal(e.currentTarget.href)
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
handleConfigChange(e) {
|
||||
const newConfig = { amaEnabled: this.refs.amaEnabled.checked }
|
||||
const newConfig = {
|
||||
amaEnabled: this.refs.amaEnabled.checked,
|
||||
autoUpdateEnabled: this.refs.autoUpdateEnabled.checked
|
||||
}
|
||||
|
||||
this.setState({ config: newConfig })
|
||||
}
|
||||
@@ -77,9 +86,7 @@ class InfoTab extends React.Component {
|
||||
}
|
||||
|
||||
handleSaveButtonClick(e) {
|
||||
const newConfig = {
|
||||
amaEnabled: this.state.config.amaEnabled
|
||||
}
|
||||
const newConfig = this.state.config
|
||||
|
||||
if (!newConfig.amaEnabled) {
|
||||
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('DISABLE_AMA')
|
||||
@@ -106,15 +113,6 @@ class InfoTab extends React.Component {
|
||||
})
|
||||
}
|
||||
|
||||
toggleAutoUpdate() {
|
||||
const newConfig = {
|
||||
autoUpdateEnabled: !this.state.config.autoUpdateEnabled
|
||||
}
|
||||
|
||||
this.setState({ config: newConfig })
|
||||
ConfigManager.set(newConfig)
|
||||
}
|
||||
|
||||
infoMessage() {
|
||||
const { amaMessage } = this.state
|
||||
return amaMessage ? <p styleName='policy-confirm'>{amaMessage}</p> : null
|
||||
@@ -260,7 +258,8 @@ class InfoTab extends React.Component {
|
||||
<label>
|
||||
<input
|
||||
type='checkbox'
|
||||
onChange={this.toggleAutoUpdate.bind(this)}
|
||||
ref='autoUpdateEnabled'
|
||||
onChange={() => this.handleConfigChange()}
|
||||
checked={this.state.config.autoUpdateEnabled}
|
||||
/>
|
||||
{i18n.__('Enable Auto Update')}
|
||||
|
||||
Reference in New Issue
Block a user