mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +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/ipcClient')
|
||||||
require('../lib/customMeta')
|
require('../lib/customMeta')
|
||||||
import i18n from 'browser/lib/i18n'
|
import i18n from 'browser/lib/i18n'
|
||||||
|
import ConfigManager from './lib/ConfigManager'
|
||||||
|
|
||||||
const electron = require('electron')
|
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(
|
ReactDOM.render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<ConnectedRouter history={history}>
|
<ConnectedRouter history={history}>
|
||||||
@@ -147,9 +163,7 @@ ReactDOM.render(
|
|||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on('update-found', function() {
|
ipcRenderer.on('update-found', function() {
|
||||||
notify('Update found!', {
|
downloadUpdate()
|
||||||
body: 'Preparing to update...'
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on('update-not-found', function(_, msg) {
|
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) {
|
handleLinkClick(e) {
|
||||||
shell.openExternal(e.currentTarget.href)
|
shell.openExternal(e.currentTarget.href)
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
handleConfigChange(e) {
|
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 })
|
this.setState({ config: newConfig })
|
||||||
}
|
}
|
||||||
@@ -77,9 +86,7 @@ class InfoTab extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSaveButtonClick(e) {
|
handleSaveButtonClick(e) {
|
||||||
const newConfig = {
|
const newConfig = this.state.config
|
||||||
amaEnabled: this.state.config.amaEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!newConfig.amaEnabled) {
|
if (!newConfig.amaEnabled) {
|
||||||
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('DISABLE_AMA')
|
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() {
|
infoMessage() {
|
||||||
const { amaMessage } = this.state
|
const { amaMessage } = this.state
|
||||||
return amaMessage ? <p styleName='policy-confirm'>{amaMessage}</p> : null
|
return amaMessage ? <p styleName='policy-confirm'>{amaMessage}</p> : null
|
||||||
@@ -260,7 +258,8 @@ class InfoTab extends React.Component {
|
|||||||
<label>
|
<label>
|
||||||
<input
|
<input
|
||||||
type='checkbox'
|
type='checkbox'
|
||||||
onChange={this.toggleAutoUpdate.bind(this)}
|
ref='autoUpdateEnabled'
|
||||||
|
onChange={() => this.handleConfigChange()}
|
||||||
checked={this.state.config.autoUpdateEnabled}
|
checked={this.state.config.autoUpdateEnabled}
|
||||||
/>
|
/>
|
||||||
{i18n.__('Enable Auto Update')}
|
{i18n.__('Enable Auto Update')}
|
||||||
|
|||||||
Reference in New Issue
Block a user