1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Ability to stop auto update

This commit is contained in:
Jack Hsieh
2018-11-17 10:46:49 -08:00
committed by Junyoung Choi
parent 7d4d176bf4
commit d78f6b7aba
5 changed files with 23 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ const win = global.process.platform === 'win32'
const electron = require('electron') const electron = require('electron')
const { ipcRenderer } = electron const { ipcRenderer } = electron
const consts = require('browser/lib/consts') const consts = require('browser/lib/consts')
const electronConfig = new (require('electron-config'))()
let isInitialized = false let isInitialized = false
@@ -26,6 +27,7 @@ export const DEFAULT_CONFIG = {
sortTagsBy: 'ALPHABETICAL', // 'ALPHABETICAL', 'COUNTER' sortTagsBy: 'ALPHABETICAL', // 'ALPHABETICAL', 'COUNTER'
listStyle: 'DEFAULT', // 'DEFAULT', 'SMALL' listStyle: 'DEFAULT', // 'DEFAULT', 'SMALL'
amaEnabled: true, amaEnabled: true,
autoUpdateEnabled: true,
hotkey: { hotkey: {
toggleMain: OSX ? 'Command + Alt + L' : 'Super + Alt + E', toggleMain: OSX ? 'Command + Alt + L' : 'Super + Alt + E',
toggleMode: OSX ? 'Command + Alt + M' : 'Ctrl + M', toggleMode: OSX ? 'Command + Alt + M' : 'Ctrl + M',
@@ -141,6 +143,8 @@ function get () {
_save(config) _save(config)
} }
config.autoUpdateEnabled = electronConfig.get('autoUpdateEnabled', config.autoUpdateEnabled)
if (!isInitialized) { if (!isInitialized) {
isInitialized = true isInitialized = true
let editorTheme = document.getElementById('editorTheme') let editorTheme = document.getElementById('editorTheme')
@@ -205,6 +209,8 @@ function set (updates) {
editorTheme.setAttribute('href', newTheme.path) editorTheme.setAttribute('href', newTheme.path)
} }
electronConfig.set('autoUpdateEnabled', newConfig.autoUpdateEnabled)
ipcRenderer.send('config-renew', { ipcRenderer.send('config-renew', {
config: get() config: get()
}) })

View File

@@ -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 () { 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
@@ -140,6 +149,8 @@ class InfoTab extends React.Component {
</li> </li>
</ul> </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' /> <hr styleName='separate-line' />
<div styleName='group-header2--sub'>{i18n.__('Analytics')}</div> <div styleName='group-header2--sub'>{i18n.__('Analytics')}</div>

View File

@@ -4,6 +4,7 @@ const Menu = electron.Menu
const ipc = electron.ipcMain const ipc = electron.ipcMain
const GhReleases = require('electron-gh-releases') const GhReleases = require('electron-gh-releases')
const { isPackaged } = app const { isPackaged } = app
const electronConfig = new (require('electron-config'))()
// electron.crashReporter.start() // electron.crashReporter.start()
const singleInstance = app.requestSingleInstanceLock() const singleInstance = app.requestSingleInstanceLock()
@@ -40,6 +41,7 @@ function checkUpdate () {
console.log('Updates are disabled in Development mode, see main-app.js') console.log('Updates are disabled in Development mode, see main-app.js')
return true return true
} }
if (!electronConfig.get('autoUpdateEnabled', true)) return
if (process.platform === 'linux' || isUpdateReady) { if (process.platform === 'linux' || isUpdateReady) {
return true return true
} }

View File

@@ -190,5 +190,6 @@
"Show menu bar": "Show menu bar", "Show menu bar": "Show menu bar",
"Auto Detect": "Auto Detect", "Auto Detect": "Auto Detect",
"Enable HTML label in mermaid flowcharts": "Enable HTML label in mermaid flowcharts ⚠ This option potentially has a risk of XSS.", "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"
} }

View File

@@ -5,7 +5,8 @@ const noop = () => {}
mock('electron', { mock('electron', {
remote: { remote: {
app: { app: {
getAppPath: noop getAppPath: noop,
getPath: noop
} }
} }
}) })