Skip to content

Commit

Permalink
Parse/use build version
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Jan 4, 2024
1 parent 5806648 commit 6b311ee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/SettingsWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ export default class SettingsWindow extends PureComponent {
<SettingsPage current={this.state.activePage} id="updates">
<div className="pageSection">
<div className="sectionTitle">{T.t("SETTINGS_UPDATES_TITLE")}</div>
<p>{T.h("SETTINGS_UPDATES_VERSION", '<b>' + (window.version || "not available") + '</b>')}</p>
<p>{T.h("SETTINGS_UPDATES_VERSION", '<b>' + (window.version ? `${window.version}${window.versionTag && window.versionBuild ? ` (${window.versionBuild})` : ""}` : "not available") + '</b>')}</p>
{this.getUpdate()}
</div>
<div className="pageSection" style={{ display: (window.isAppX ? "none" : (this.isSection("updates") ? "block" : "none")) }}>
Expand Down
27 changes: 19 additions & 8 deletions src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const { BrowserWindow, nativeTheme, systemPreferences, Menu, ipcMain, app, scree
const Utils = require("./Utils")
const uuid = require('crypto').randomUUID

const appVersionFull = app.getVersion()
const appVersion = appVersionFull.split('+')[0]
const appVersionTag = appVersion?.split('-')[1]
const appBuild = appVersionFull.split('+')[1]
const appBuildShort = (appBuild && appBuild.length > 7 ? appBuild.slice(0, 7) : appBuild)

// Expose GC
app.commandLine.appendSwitch('js-flags', '--expose_gc --max-old-space-size=128')
app.commandLine.appendSwitch('disable-http-cache')
Expand Down Expand Up @@ -325,12 +331,12 @@ function pingAnalytics() {
events.push({
name: "page_view",
params: {
page_location: app.name + "/" + "v" + app.getVersion(),
page_title: app.name + "/" + "v" + app.getVersion(),
page_location: app.name + "/" + "v" + appVersion + "/" + (appBuild ? appBuild : ""),
page_title: app.name + "/" + "v" + appVersion,
page_referrer: app.name,
os_version: require("os").release(),
app_type: app.name,
app_version: app.getVersion(),
app_version: appVersion,
engagement_time_msec: 1
}
})
Expand Down Expand Up @@ -367,6 +373,8 @@ if (!fs.existsSync(configFilesDir)) {

const defaultSettings = {
isDev,
settingsVer: "v" + appVersion,
settingsBuild: appBuild,
userClosedIntro: false,
theme: "default",
icon: "icon",
Expand All @@ -391,7 +399,6 @@ const defaultSettings = {
checkForUpdates: !isDev,
dismissedUpdate: '',
language: "system",
settingsVer: "v" + app.getVersion(),
names: {},
analytics: !isDev,
scrollShortcut: true,
Expand Down Expand Up @@ -625,7 +632,7 @@ function processSettings(newSettings = {}, sendUpdate = true) {

try {

settings.settingsVer = "v" + app.getVersion()
settings.settingsVer = "v" + appVersion

if (settings.theme) {
nativeTheme.themeSource = determineTheme(settings.theme)
Expand Down Expand Up @@ -2188,7 +2195,9 @@ function createPanel(toggleOnLoad = false, isRefreshing = false) {
zoomFactor: 1.0,
additionalArguments: ["jsVars" + Buffer.from(JSON.stringify({
appName: app.name,
appVersion: app.getVersion(),
appVersion: appVersion,
appVersionTag: appVersionTag,
appBuild: appBuildShort,
isRefreshing: isRefreshing
})).toString('base64')],
allowRunningInsecureContent: true,
Expand Down Expand Up @@ -3112,7 +3121,9 @@ function createSettings() {
zoomFactor: 1.0,
additionalArguments: ["jsVars" + Buffer.from(JSON.stringify({
appName: app.name,
appVersion: app.getVersion(),
appVersion: appVersion,
appVersionTag: appVersionTag,
appBuild: appBuildShort,
settings,
lastTheme,
settingsPath
Expand Down Expand Up @@ -3226,7 +3237,7 @@ checkForUpdates = async (force = false) => {
}
}

if (foundVersion && "v" + app.getVersion() != latestVersion.version && (settings.dismissedUpdate != latestVersion.version || force)) {
if (foundVersion && "v" + appVersion != latestVersion.version && (settings.dismissedUpdate != latestVersion.version || force)) {
if (!force) latestVersion.show = true
console.log("Sending new version to windows.")
sendToAllWindows('latest-version', latestVersion)
Expand Down
2 changes: 2 additions & 0 deletions src/settings-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,7 @@ window.accent = "cyan"
window.getSunCalcTimes = getSunCalcTimes

window.version = 'v' + getArgumentVars().appVersion
window.versionTag = getArgumentVars().appVersionTag
window.versionBuild = getArgumentVars().appBuild
window.isAppX = (getArgumentVars().appName == "twinkle-tray-appx" ? true : false)
window.settingsPath = getArgumentVars().settingsPath

0 comments on commit 6b311ee

Please sign in to comment.