Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to stop auto update #2617

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions browser/main/lib/ConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const win = global.process.platform === 'win32'
const electron = require('electron')
const { ipcRenderer } = electron
const consts = require('browser/lib/consts')
const electronConfig = new (require('electron-config'))()

let isInitialized = false

Expand All @@ -26,6 +27,7 @@ export const DEFAULT_CONFIG = {
sortTagsBy: 'ALPHABETICAL', // 'ALPHABETICAL', 'COUNTER'
listStyle: 'DEFAULT', // 'DEFAULT', 'SMALL'
amaEnabled: true,
autoUpdateEnabled: true,
hotkey: {
toggleMain: OSX ? 'Command + Alt + L' : 'Super + Alt + E',
toggleMode: OSX ? 'Command + Alt + M' : 'Ctrl + M',
Expand Down Expand Up @@ -141,6 +143,8 @@ function get () {
_save(config)
}

config.autoUpdateEnabled = electronConfig.get('autoUpdateEnabled', config.autoUpdateEnabled)

if (!isInitialized) {
isInitialized = true
let editorTheme = document.getElementById('editorTheme')
Expand Down Expand Up @@ -205,6 +209,8 @@ function set (updates) {
editorTheme.setAttribute('href', newTheme.path)
}

electronConfig.set('autoUpdateEnabled', newConfig.autoUpdateEnabled)

ipcRenderer.send('config-renew', {
config: get()
})
Expand Down
11 changes: 11 additions & 0 deletions browser/main/modals/PreferencesModal/InfoTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ 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
Expand Down Expand Up @@ -140,6 +149,8 @@ class InfoTab extends React.Component {
</li>
</ul>

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

<hr styleName='separate-line' />

<div styleName='group-header2--sub'>{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 @@ -4,6 +4,7 @@ const Menu = electron.Menu
const ipc = electron.ipcMain
const GhReleases = require('electron-gh-releases')
const { isPackaged } = app
const electronConfig = new (require('electron-config'))()
// electron.crashReporter.start()
const singleInstance = app.requestSingleInstanceLock()

Expand Down Expand Up @@ -40,6 +41,7 @@ function checkUpdate () {
console.log('Updates are disabled in Development mode, see main-app.js')
return true
}
if (!electronConfig.get('autoUpdateEnabled', true)) return
if (process.platform === 'linux' || isUpdateReady) {
return true
}
Expand Down
3 changes: 2 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,6 @@
"Show menu bar": "Show menu bar",
"Auto Detect": "Auto Detect",
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.",
"Wrap line in Snippet Note": "Wrap line in Snippet Note"
"Wrap line in Snippet Note": "Wrap line in Snippet Note",
"Enable Auto Update": "Enable Auto Update"
}
3 changes: 2 additions & 1 deletion tests/helpers/setup-electron-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const noop = () => {}
mock('electron', {
remote: {
app: {
getAppPath: noop
getAppPath: noop,
getPath: noop
}
}
})