Skip to content

Commit

Permalink
Add version number to settings dialog.
Browse files Browse the repository at this point in the history
For the web app we also display the git hash.
  • Loading branch information
heyman committed Jan 12, 2024
1 parent 37b62d4 commit 295e555
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
6 changes: 2 additions & 4 deletions electron/main/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { app, BrowserWindow, nativeTheme } from 'electron'

import { win } from "./index"
import CONFIG from "../config"
import { getVersionString } from './version'

let aboutWindow = null;

Expand Down Expand Up @@ -33,10 +34,7 @@ export function openAboutWindow() {
aboutWindow.loadFile(join(process.env.DIST, 'about.html'))
}

let versionString = app.getVersion()
if (CONFIG.get("settings.allowBetaVersions")) {
versionString += " (beta channel)"
}
let versionString = getVersionString()

// don't show until content is loaded
aboutWindow.webContents.on("did-finish-load", () => {
Expand Down
12 changes: 12 additions & 0 deletions electron/main/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { app, ipcMain } from "electron"
import CONFIG from "../config"

export function getVersionString() {
let versionString = app.getVersion()
if (CONFIG.get("settings.allowBetaVersions")) {
versionString += " (beta channel)"
}
return versionString
}

ipcMain.handle("getVersion", () => getVersionString())
4 changes: 4 additions & 0 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ contextBridge.exposeInMainWorld("heynote", {
ipcRenderer.invoke(UPDATE_CHECK_FOR_UPDATES)
},
},

async getVersion() {
return await ipcRenderer.invoke("getVersion")
}
})


Expand Down
17 changes: 13 additions & 4 deletions src/components/settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
customBufferLocation: !!this.initialSettings.bufferPath,
systemFonts: [[defaultFontFamily, defaultFontFamily + " (default)"]],
defaultFontSize: defaultFontSize,
appVersion: "",
}
},
Expand All @@ -56,6 +57,8 @@
window.addEventListener("keydown", this.onKeyDown);
this.$refs.keymapSelector.focus()
this.appVersion = await window.heynote.getVersion()
},
beforeUnmount() {
window.removeEventListener("keydown", this.onKeyDown);
Expand Down Expand Up @@ -134,8 +137,7 @@
@click="activeTab = 'appearance'"
/>
<TabListItem
v-if="!isWebApp"
name="Updates"
:name="isWebApp ? 'Version' : 'Updates'"
tab="updates"
:activeTab="activeTab"
@click="activeTab = 'updates'"
Expand Down Expand Up @@ -292,8 +294,15 @@
</div>
</TabContent>

<TabContent tab="updates" :activeTab="activeTab" v-if="!isWebApp">
<TabContent tab="updates" :activeTab="activeTab">
<div class="row">
<div class="entry">
<h2>Current Version</h2>
<b>{{ appVersion }}</b>
</div>
</div>

<div class="row" v-if="!isWebApp">
<div class="entry">
<h2>Auto Update</h2>
<label>
Expand All @@ -306,7 +315,7 @@
</label>
</div>
</div>
<div class="row">
<div class="row" v-if="!isWebApp">
<div class="entry">
<h2>Beta Versions</h2>
<label>
Expand Down
4 changes: 4 additions & 0 deletions webapp/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ const Heynote = {
currencyData = JSON.parse(await response.text())
return currencyData
},

async getVersion() {
return __APP_VERSION__ + " (" + __GIT_HASH__ + ")"
},
}

export { Heynote, ipcRenderer}
8 changes: 6 additions & 2 deletions webapp/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import path from 'path'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
//import { directoryPlugin } from "vite-plugin-list-directory-contents";

import * as child from "child_process";

const middleware = () => {
return {
Expand Down Expand Up @@ -33,7 +33,6 @@ export default defineConfig({

plugins: [
vue(),
//directoryPlugin({ baseDir: __dirname }),
],

css: {
Expand All @@ -51,4 +50,9 @@ export default defineConfig({
'@': path.resolve(__dirname, '..'),
},
},

define: {
'__APP_VERSION__': JSON.stringify(process.env.npm_package_version),
'__GIT_HASH__': JSON.stringify(child.execSync('git rev-parse --short HEAD').toString().trim()),
},
})

0 comments on commit 295e555

Please sign in to comment.