Skip to content

Commit

Permalink
Ability to stop auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
hsiehjack committed Nov 18, 2018
1 parent a26d4fb commit 409ec4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion browser/main/modals/PreferencesModal/InfoTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import i18n from 'browser/lib/i18n'
const electron = require('electron')
const { shell, remote } = electron
const appVersion = remote.app.getVersion()
const Config = new (require('electron-config'))()

class InfoTab extends React.Component {
constructor (props) {
super(props)

this.state = {
config: this.props.config
config: this.props.config,
autoUpdateEnabled: Config.get('autoUpdateEnabled')
}
}

Expand Down Expand Up @@ -61,6 +63,14 @@ class InfoTab extends React.Component {
})
}

handleAutoUpdateState (e) {
this.setState(state => {
const isEnabled = !state.autoUpdateEnabled
Config.set('autoUpdateEnabled', isEnabled)
return {autoUpdateEnabled: isEnabled}
})
}

infoMessage () {
const { amaMessage } = this.state
return amaMessage ? <p styleName='policy-confirm'>{amaMessage}</p> : null
Expand Down Expand Up @@ -136,6 +146,8 @@ class InfoTab extends React.Component {
</li>
</ul>

<div><label><input type='checkbox' onChange={e => this.handleAutoUpdateState(e)} checked={this.state.autoUpdateEnabled} />{i18n.__('Enable Auto Update')}</label></div>

<hr styleName='separate-line' />

<div styleName='policy'>{i18n.__('Analytics')}</div>
Expand Down
2 changes: 2 additions & 0 deletions lib/main-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const app = electron.app
const Menu = electron.Menu
const ipc = electron.ipcMain
const GhReleases = require('electron-gh-releases')
const config = new (require('electron-config'))()
// electron.crashReporter.start()
var ipcServer = null

Expand Down Expand Up @@ -35,6 +36,7 @@ const updater = new GhReleases(ghReleasesOpts)
// Check for updates
// `status` returns true if there is a new update available
function checkUpdate () {
if (!config.get('autoUpdateEnabled', true)) return
if (process.platform === 'linux' || isUpdateReady) {
return true
}
Expand Down

0 comments on commit 409ec4a

Please sign in to comment.