Fix auto updating beta versions by setting autoUpdater.allowPrerelease instead of autoUpdater.channel

This commit is contained in:
Jonatan Heyman 2023-12-07 00:42:29 +01:00
parent 3b1aae8e15
commit 6e9195c835
7 changed files with 45 additions and 28 deletions

View File

@ -25,7 +25,7 @@ const schema = {
"emacsMetaKey": { "enum": [null, "alt", "meta"], default: null },
"showLineNumberGutter": {type: "boolean", default:true},
"showFoldGutter": {type: "boolean", default:true},
"releaseChannel": {enum: [null, "beta"], default: null},
"allowBetaVersions": {type: "boolean", default: false},
},
},
@ -46,7 +46,7 @@ const defaults = {
emacsMetaKey: "meta",
showLineNumberGutter: true,
showFoldGutter: true,
releaseChannel: null,
allowBetaVersions: false,
},
theme: "system",
}

View File

@ -25,9 +25,6 @@ autoUpdater.logger.transports.file.level = "info"
autoUpdater.autoDownload = false
// set channel
autoUpdater.channel = CONFIG.get("settings.releaseChannel")
autoUpdater.on('error', (error) => {
window?.webContents.send(UPDATE_ERROR, error == null ? "unknown" : (error.stack || error).toString())
//dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString())
@ -69,8 +66,7 @@ ipcMain.handle(UPDATE_INSTALL_AND_RESTART, () => {
export function checkForUpdates() {
const settingsChannel = CONFIG.get("settings.releaseChannel")
autoUpdater.channel = (settingsChannel === null ? "latest" : settingsChannel)
autoUpdater.allowPrerelease = CONFIG.get("settings.allowBetaVersions")
autoUpdater.checkForUpdates()
// for development, the autoUpdater will not work, so we need to trigger the event manually
if (process.env.NODE_ENV === "development") {
@ -84,4 +80,17 @@ ipcMain.handle(UPDATE_CHECK_FOR_UPDATES, () => {
export function initializeAutoUpdate(win) {
window = win
/**
* To debug auto updates (actually downloading an update won't work),
* uncomment the lines below, and create a dev-app-update.yml with the content:
*
* owner: heyman
* repo: heynote
* provider: github
*/
// Useful for some dev/debugging tasks, but download can
// not be validated becuase dev app is not signed
//autoUpdater.updateConfigPath = "/Users/heyman/projects/heynote/dev-app-update.yml" //path.join(__dirname, 'dev-app-update.yml');
//autoUpdater.forceDevUpdateConfig = true;
}

View File

@ -62,7 +62,7 @@ let contentSaved = false
// if this version is a beta version, set the release channel to beta
const isBetaVersion = app.getVersion().includes("beta")
if (isBetaVersion) {
CONFIG.set("settings.releaseChannel", "beta")
CONFIG.set("settings.allowBetaVersions", true)
}
@ -212,13 +212,6 @@ ipcMain.handle('settings:set', (event, settings) => {
if (settings.keymap !== CONFIG.get("settings.keymap")) {
currentKeymap = settings.keymap
}
const releaseChannelChanged = settings.releaseChannel !== CONFIG.get("settings.releaseChannel")
CONFIG.set("settings", settings)
if (releaseChannelChanged) {
// release channel changed, check for updates
checkForUpdates()
}
win?.webContents.send(SETTINGS_CHANGE_EVENT, settings)
})

View File

@ -121,6 +121,7 @@
:languageAuto="languageAuto"
:theme="theme"
:systemTheme="systemTheme"
:allowBetaVersions="settings.allowBetaVersions"
@toggleTheme="toggleTheme"
@openLanguageSelector="openLanguageSelector"
@formatCurrentBlock="formatCurrentBlock"

View File

@ -13,6 +13,7 @@
"languageAuto",
"theme",
"systemTheme",
"allowBetaVersions",
],
components: {
@ -63,7 +64,7 @@
>
<span class="icon icon-format"></span>
</div>
<UpdateStatusItem />
<UpdateStatusItem :allowBetaVersions="allowBetaVersions" />
<div class="status-block theme clickable" @click="$emit('toggleTheme')" title="Toggle dark/light mode">
<span :class="'icon ' + systemTheme"></span>
</div>

View File

@ -1,5 +1,9 @@
<script>
export default {
props: [
"allowBetaVersions",
],
data() {
return {
updateAvailable: false,
@ -62,6 +66,14 @@
}
},
watch: {
allowBetaVersions: {
handler: function (newValue) {
this.checkForUpdate()
},
}
},
computed: {
statusText() {
if (this.downloading) {
@ -123,6 +135,7 @@
},
checkForUpdate() {
this.updateAvailable = false
this.checkingForUpdate = true
window.heynote.autoUpdate.checkForUpdates()
}

View File

@ -16,11 +16,7 @@
isMac: window.heynote.platform.isMac,
showLineNumberGutter: this.initialSettings.showLineNumberGutter,
showFoldGutter: this.initialSettings.showFoldGutter,
releaseChannels: [
{ name: "Stable", value: null },
{ name: "Beta", value: "beta" },
],
releaseChannel: this.initialSettings.releaseChannel,
allowBetaVersions: this.initialSettings.allowBetaVersions,
}
},
@ -45,7 +41,7 @@
showFoldGutter: this.showFoldGutter,
keymap: this.keymap,
emacsMetaKey: this.metaKey,
releaseChannel: this.releaseChannel,
allowBetaVersions: this.allowBetaVersions,
})
}
}
@ -99,12 +95,16 @@
</div>
<div class="row">
<div class="entry">
<h2>Release Channel</h2>
<select ref="releaseChannelSelector" v-model="releaseChannel" @change="updateSettings">
<template v-for="rc in releaseChannels" :key="rc.value">
<option :selected="rc.value === releaseChannel" :value="rc.value">{{ rc.name }}</option>
</template>
</select>
<h2>Beta Versions</h2>
<div class="checkbox">
<input
type="checkbox"
id="allowBetaVersions"
v-model="allowBetaVersions"
@change="updateSettings"
/>
<label for="allowBetaVersions">Use beta versions of Heynote</label>
</div>
</div>
</div>
</div>