1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-15 18:56:22 +00:00

Compare commits

..

9 Commits

Author SHA1 Message Date
dependabot[bot]
8b64773a7e Bump dot-prop from 4.2.0 to 4.2.1
Bumps [dot-prop](https://github.com/sindresorhus/dot-prop) from 4.2.0 to 4.2.1.
- [Release notes](https://github.com/sindresorhus/dot-prop/releases)
- [Commits](https://github.com/sindresorhus/dot-prop/compare/v4.2.0...v4.2.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-11 15:16:26 +00:00
Gonçalo Santos
2603dfc1ed Fix Analytics save bug 2020-12-12 00:15:37 +09:00
Gonçalo Santos
2df590600b AutoUpdate is auto saved 2020-12-12 00:15:37 +09:00
Gonçalo Santos
ef20a8f3e5 Remove debug statements 2020-12-12 00:15:37 +09:00
Gonçalo Santos
3e405e1abf Fix Cancel update 2020-12-12 00:15:37 +09:00
Gonçalo Santos
553832bdfa Create confirm download dialog 2020-12-12 00:15:37 +09:00
Gonçalo Santos
18d65d999a Menu item calls update-check 2020-12-12 00:15:37 +09:00
Gonçalo Santos
3b5eff582a Update not found message 2020-12-12 00:15:37 +09:00
Gonçalo Santos
85d09b3b3d Add update menu item 2020-12-12 00:15:37 +09:00
7 changed files with 89 additions and 28 deletions

View File

@@ -18,6 +18,7 @@ import { getLocales } from 'browser/lib/Languages'
import applyShortcuts from 'browser/main/lib/shortcutManager'
import { chooseTheme, applyTheme } from 'browser/main/lib/ThemeManager'
import { push } from 'connected-react-router'
import { ipcRenderer } from 'electron'
const path = require('path')
const electron = require('electron')
@@ -184,6 +185,7 @@ class Main extends React.Component {
this.toggleMenuBarVisible.bind(this)
)
eventEmitter.on('dispatch:push', this.changeRoutePush.bind(this))
eventEmitter.on('update', () => ipcRenderer.send('update-check', 'manual'))
}
componentWillUnmount() {

View File

@@ -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,22 @@ 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-download-confirm')
} else if (index === 1) {
ipcRenderer.send('update-cancel')
ConfigManager.set({ autoUpdateEnabled: false })
}
}
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
@@ -147,8 +164,12 @@ ReactDOM.render(
})
ipcRenderer.on('update-found', function() {
notify('Update found!', {
body: 'Preparing to update...'
downloadUpdate()
})
ipcRenderer.on('update-not-found', function(_, msg) {
notify('Update not found!', {
body: msg
})
})

View File

@@ -23,15 +23,25 @@ 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 })
return newConfig
}
handleSubscriptionFormSubmit(e) {
@@ -77,9 +87,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,20 +114,17 @@ 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
}
handleAutoUpdateChange() {
const { autoUpdateEnabled } = this.handleConfigChange()
ConfigManager.set({ autoUpdateEnabled })
}
render() {
return (
<div styleName='root'>
@@ -260,7 +265,8 @@ class InfoTab extends React.Component {
<label>
<input
type='checkbox'
onChange={this.toggleAutoUpdate.bind(this)}
ref='autoUpdateEnabled'
onChange={() => this.handleAutoUpdateChange()}
checked={this.state.config.autoUpdateEnabled}
/>
{i18n.__('Enable Auto Update')}

View File

@@ -26,6 +26,7 @@ if (!singleInstance) {
}
var isUpdateReady = false
let updateFound = false
var ghReleasesOpts = {
repo: 'BoostIO/boost-releases',
@@ -36,25 +37,33 @@ const updater = new GhReleases(ghReleasesOpts)
// Check for updates
// `status` returns true if there is a new update available
function checkUpdate() {
function checkUpdate(manualTriggered = false) {
if (!isPackaged) {
// Prevents app from attempting to update when in dev mode.
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) {
// End if auto updates disabled and it is an automatic check
if (!electronConfig.get('autoUpdateEnabled', true) && !manualTriggered) return
if (process.platform === 'linux' || isUpdateReady || updateFound) {
return true
}
updater.check((err, status) => {
if (err) {
var isLatest = err.message === 'There is no newer version.'
if (!isLatest) console.error('Updater error! %s', err.message)
mainWindow.webContents.send(
'update-not-found',
isLatest ? 'There is no newer version.' : 'Updater error'
)
return
}
if (status) {
mainWindow.webContents.send('update-found', 'Update available!')
updater.download()
updateFound = true
}
})
}
@@ -63,6 +72,7 @@ updater.on('update-downloaded', info => {
if (mainWindow != null) {
mainWindow.webContents.send('update-ready', 'Update available!')
isUpdateReady = true
updateFound = false
}
})
@@ -77,6 +87,14 @@ ipc.on('update-app-confirm', function(event, msg) {
}
})
ipc.on('update-cancel', () => {
updateFound = false
})
ipc.on('update-download-confirm', () => {
updater.download()
})
app.on('window-all-closed', function() {
app.quit()
})
@@ -113,7 +131,7 @@ app.on('ready', function() {
if (isUpdateReady) {
mainWindow.webContents.send('update-ready', 'Update available!')
} else {
checkUpdate()
checkUpdate(msg === 'manual')
}
})
}, 10 * 1000)

View File

@@ -178,6 +178,18 @@ const file = {
mainWindow.webContents.send('list:isMarkdownNote', 'print')
mainWindow.webContents.send('print')
}
},
{
type: 'separator'
},
{
label: 'Update',
click() {
mainWindow.webContents.send('update')
}
},
{
type: 'separator'
}
]
}

View File

@@ -72,7 +72,7 @@
"flowchart.js": "^1.6.5",
"font-awesome": "^4.3.0",
"fs-extra": "^5.0.0",
"highlight.js": "^10.4.1",
"highlight.js": "^9.13.1",
"i18n-2": "^0.7.2",
"iconv-lite": "^0.4.19",
"immutable": "^3.8.1",

View File

@@ -2962,8 +2962,9 @@ domutils@^1.5.1:
domelementtype "1"
dot-prop@^4.1.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57"
version "4.2.1"
resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.1.tgz#45884194a71fc2cda71cbb4bceb3a4dd2f433ba4"
integrity sha512-l0p4+mIuJIua0mhxGoh4a+iNL9bmeK5DvnSVQa6T0OhrVmaEa1XScX5Etc673FePCJOArq/4Pa2cLGODUWTPOQ==
dependencies:
is-obj "^1.0.0"
@@ -4560,10 +4561,10 @@ he@^1.1.1, he@^1.2.0:
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
highlight.js@^10.4.1:
version "10.4.1"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.4.1.tgz#d48fbcf4a9971c4361b3f95f302747afe19dbad0"
integrity sha512-yR5lWvNz7c85OhVAEAeFhVCc/GV4C30Fjzc/rCP0aCWzc1UUOPUk55dK/qdwTZHBvMZo+eZ2jpk62ndX/xMFlg==
highlight.js@^9.13.1:
version "9.13.1"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.13.1.tgz#054586d53a6863311168488a0f58d6c505ce641e"
integrity sha512-Sc28JNQNDzaH6PORtRLMvif9RSn1mYuOoX3omVjnb0+HbpPygU2ALBI0R/wsiqCb4/fcp07Gdo8g+fhtFrQl6A==
highlight.js@^9.3.0:
version "9.12.0"
@@ -5129,6 +5130,7 @@ is-number@^4.0.0:
is-obj@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f"
integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8=
is-observable@^0.2.0:
version "0.2.0"