mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
Menu item calls update-check
This commit is contained in:
committed by
Junyoung Choi
parent
3b5eff582a
commit
18d65d999a
@@ -18,6 +18,7 @@ import { getLocales } from 'browser/lib/Languages'
|
|||||||
import applyShortcuts from 'browser/main/lib/shortcutManager'
|
import applyShortcuts from 'browser/main/lib/shortcutManager'
|
||||||
import { chooseTheme, applyTheme } from 'browser/main/lib/ThemeManager'
|
import { chooseTheme, applyTheme } from 'browser/main/lib/ThemeManager'
|
||||||
import { push } from 'connected-react-router'
|
import { push } from 'connected-react-router'
|
||||||
|
import { ipcRenderer } from 'electron'
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
@@ -184,6 +185,7 @@ class Main extends React.Component {
|
|||||||
this.toggleMenuBarVisible.bind(this)
|
this.toggleMenuBarVisible.bind(this)
|
||||||
)
|
)
|
||||||
eventEmitter.on('dispatch:push', this.changeRoutePush.bind(this))
|
eventEmitter.on('dispatch:push', this.changeRoutePush.bind(this))
|
||||||
|
eventEmitter.on('update', () => ipcRenderer.send('update-check', 'manual'))
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
|||||||
@@ -36,20 +36,25 @@ const updater = new GhReleases(ghReleasesOpts)
|
|||||||
|
|
||||||
// Check for updates
|
// Check for updates
|
||||||
// `status` returns true if there is a new update available
|
// `status` returns true if there is a new update available
|
||||||
function checkUpdate() {
|
function checkUpdate(manualTriggered = false) {
|
||||||
if (!isPackaged) {
|
// if (!isPackaged) {
|
||||||
// Prevents app from attempting to update when in dev mode.
|
// Prevents app from attempting to update when in dev mode.
|
||||||
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 (!electronConfig.get('autoUpdateEnabled', true) && !manualTriggered) return
|
||||||
if (process.platform === 'linux' || isUpdateReady) {
|
// if (process.platform === 'linux' || isUpdateReady) {
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
|
|
||||||
updater.check((err, status) => {
|
updater.check((err, status) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
var isLatest = err.message === 'There is no newer version.'
|
var isLatest = err.message === 'There is no newer version.'
|
||||||
if (!isLatest) console.error('Updater error! %s', err.message)
|
if (!isLatest) console.error('Updater error! %s', err.message)
|
||||||
|
mainWindow.webContents.send(
|
||||||
|
'update-not-found',
|
||||||
|
isLatest ? 'There is no newer version.' : 'Updater error'
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
@@ -113,7 +118,7 @@ app.on('ready', function() {
|
|||||||
if (isUpdateReady) {
|
if (isUpdateReady) {
|
||||||
mainWindow.webContents.send('update-ready', 'Update available!')
|
mainWindow.webContents.send('update-ready', 'Update available!')
|
||||||
} else {
|
} else {
|
||||||
checkUpdate()
|
checkUpdate(msg === 'manual')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 10 * 1000)
|
}, 10 * 1000)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ const BrowserWindow = electron.BrowserWindow
|
|||||||
const shell = electron.shell
|
const shell = electron.shell
|
||||||
const ipc = electron.ipcMain
|
const ipc = electron.ipcMain
|
||||||
const mainWindow = require('./main-window')
|
const mainWindow = require('./main-window')
|
||||||
const { checkUpdate } = require('./main-app')
|
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
|
|
||||||
const macOS = process.platform === 'darwin'
|
const macOS = process.platform === 'darwin'
|
||||||
@@ -186,7 +185,7 @@ const file = {
|
|||||||
{
|
{
|
||||||
label: 'Update',
|
label: 'Update',
|
||||||
click() {
|
click() {
|
||||||
checkUpdate()
|
mainWindow.webContents.send('update')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user