mirror of
https://github.com/heyman/heynote.git
synced 2024-11-21 23:43:22 +01:00
Add release channels (Stable and Beta)
This commit is contained in:
parent
4b73d8d35c
commit
0c55dcecb0
@ -25,6 +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},
|
||||
},
|
||||
},
|
||||
|
||||
@ -45,6 +46,7 @@ const defaults = {
|
||||
emacsMetaKey: "meta",
|
||||
showLineNumberGutter: true,
|
||||
showFoldGutter: true,
|
||||
releaseChannel: null,
|
||||
},
|
||||
theme: "system",
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { autoUpdater } from "electron-updater"
|
||||
import { app, dialog, ipcMain } from "electron"
|
||||
import CONFIG from "../config"
|
||||
|
||||
import {
|
||||
UPDATE_AVAILABLE_EVENT,
|
||||
@ -10,7 +11,7 @@ import {
|
||||
UPDATE_START_DOWNLOAD,
|
||||
UPDATE_INSTALL_AND_RESTART,
|
||||
UPDATE_CHECK_FOR_UPDATES,
|
||||
} from '../constants'
|
||||
} from '../constants'
|
||||
|
||||
|
||||
// will reference the main window
|
||||
@ -24,6 +25,9 @@ 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())
|
||||
@ -63,12 +67,19 @@ ipcMain.handle(UPDATE_INSTALL_AND_RESTART, () => {
|
||||
setImmediate(() => autoUpdater.quitAndInstall(true, true))
|
||||
})
|
||||
|
||||
ipcMain.handle(UPDATE_CHECK_FOR_UPDATES, () => {
|
||||
|
||||
export function checkForUpdates() {
|
||||
const settingsChannel = CONFIG.get("settings.releaseChannel")
|
||||
autoUpdater.channel = (settingsChannel === null ? "latest" : settingsChannel)
|
||||
autoUpdater.checkForUpdates()
|
||||
// for development, the autoUpdater will not work, so we need to trigger the event manually
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
window?.webContents.send(UPDATE_NOT_AVAILABLE_EVENT)
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.handle(UPDATE_CHECK_FOR_UPDATES, () => {
|
||||
checkForUpdates()
|
||||
})
|
||||
|
||||
export function initializeAutoUpdate(win) {
|
||||
|
@ -9,7 +9,7 @@ import { WINDOW_CLOSE_EVENT, SETTINGS_CHANGE_EVENT } from '../constants';
|
||||
import CONFIG from "../config"
|
||||
import { onBeforeInputEvent } from "../keymap"
|
||||
import { isMac } from '../detect-platform';
|
||||
import { initializeAutoUpdate } from './auto-update';
|
||||
import { initializeAutoUpdate, checkForUpdates } from './auto-update';
|
||||
import { fixElectronCors } from './cors';
|
||||
|
||||
|
||||
@ -59,6 +59,12 @@ const isDev = !!process.env.VITE_DEV_SERVER_URL
|
||||
let currentKeymap = CONFIG.get("settings.keymap")
|
||||
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")
|
||||
}
|
||||
|
||||
|
||||
async function createWindow() {
|
||||
// read any stored window settings from config, or use defaults
|
||||
@ -206,6 +212,13 @@ 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)
|
||||
})
|
||||
|
@ -14,6 +14,7 @@
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.heynote.app",
|
||||
"generateUpdatesFilesForAllChannels": true,
|
||||
"directories": {
|
||||
"buildResources": "resources"
|
||||
}
|
||||
|
@ -16,6 +16,11 @@
|
||||
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,
|
||||
}
|
||||
},
|
||||
|
||||
@ -40,6 +45,7 @@
|
||||
showFoldGutter: this.showFoldGutter,
|
||||
keymap: this.keymap,
|
||||
emacsMetaKey: this.metaKey,
|
||||
releaseChannel: this.releaseChannel,
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -91,6 +97,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
@click="$emit('closeSettings')"
|
||||
|
Loading…
Reference in New Issue
Block a user