Skip to content

Build your personal knowledge base with Trilium Notes

fix(client-standalone): version check was broken

Elian Doranaf346f455a48
diff --git a/apps/client-standalone/src/lightweight/browser_routes.ts b/apps/client-standalone/src/lightweight/browser_routes.ts
index b47974ecdc..f4e3befd9c 100644
--- a/apps/client-standalone/src/lightweight/browser_routes.ts
+++ b/apps/client-standalone/src/lightweight/browser_routes.ts
@@ -58,6 +58,7 @@ function bootstrapRoute() {
const assetPath = ".";
return {
+ triliumVersion: "1.2.3",
assetPath,
baseApiUrl: "../api/",
themeCssUrl: null,
@@ -67,6 +68,7 @@ function bootstrapRoute() {
layoutOrientation: "vertical",
platform: "web",
isElectron: false,
+ isStandalone: true,
hasNativeTitleBar: false,
hasBackgroundEffects: true,
currentLocale: { id: "en", rtl: false },
diff --git a/apps/client/src/services/utils.ts b/apps/client/src/services/utils.ts
index 74de008845..055067009d 100644
--- a/apps/client/src/services/utils.ts
+++ b/apps/client/src/services/utils.ts
@@ -133,6 +133,8 @@ export function isElectron() {
return !!(window && window.process && window.process.type);
}
+export const isStandalone = window.glob.isStandalone;
+
/**
* Returns `true` if the client is running as a PWA, otherwise `false`.
*/
@@ -814,7 +816,7 @@ function compareVersions(v1: string, v2: string): number {
/**
* Compares two semantic version strings and returns `true` if the latest version is greater than the current version.
*/
-function isUpdateAvailable(latestVersion: string | null | undefined, currentVersion: string): boolean {
+export function isUpdateAvailable(latestVersion: string | null | undefined, currentVersion: string): boolean {
if (!latestVersion) {
return false;
}
diff --git a/apps/client/src/types.d.ts b/apps/client/src/types.d.ts
index 4572c4030c..4985eb6247 100644
--- a/apps/client/src/types.d.ts
+++ b/apps/client/src/types.d.ts
@@ -36,6 +36,7 @@ interface CustomGlobals {
isProtectedSessionAvailable: boolean;
isDev: boolean;
isMainWindow: boolean;
+ isStandalone?: boolean;
maxEntityChangeIdAtLoad: number;
maxEntityChangeSyncIdAtLoad: number;
assetPath: string;
diff --git a/apps/client/src/widgets/buttons/global_menu.tsx b/apps/client/src/widgets/buttons/global_menu.tsx
index 255cf89c9f..732286a36f 100644
--- a/apps/client/src/widgets/buttons/global_menu.tsx
+++ b/apps/client/src/widgets/buttons/global_menu.tsx
@@ -8,7 +8,7 @@ import { CommandNames } from "../../components/app_context";
import Component from "../../components/component";
import { ExperimentalFeature, ExperimentalFeatureId, experimentalFeatures, isExperimentalFeatureEnabled, toggleExperimentalFeature } from "../../services/experimental_features";
import { t } from "../../services/i18n";
-import utils, { dynamicRequire, isElectron, isMobile, reloadFrontendApp } from "../../services/utils";
+import utils, { dynamicRequire, isElectron, isMobile, isStandalone, reloadFrontendApp } from "../../services/utils";
import Dropdown from "../react/Dropdown";
import { FormDropdownDivider, FormDropdownSubmenu, FormListHeader, FormListItem } from "../react/FormList";
import { useStaticTooltip, useStaticTooltipWithKeyboardShortcut, useTriliumOption, useTriliumOptionBool, useTriliumOptionInt } from "../react/hooks";
@@ -249,7 +249,7 @@ function ToggleWindowOnTop() {
function useTriliumUpdateStatus() {
const [ latestVersion, setLatestVersion ] = useState<string>();
const [ checkForUpdates ] = useTriliumOptionBool("checkForUpdates");
- const isUpdateAvailable = utils.isUpdateAvailable(latestVersion, glob.triliumVersion);
+ const isUpdateAvailable = utils.isUpdateAvailable(latestVersion, window.glob.triliumVersion);
async function updateVersionStatus() {
const RELEASES_API_URL = "https://api.github.com/repos/TriliumNext/Trilium/releases/latest";
@@ -267,7 +267,7 @@ function useTriliumUpdateStatus() {
}
useEffect(() => {
- if (!checkForUpdates) {
+ if (!checkForUpdates || !isStandalone) {
setLatestVersion(undefined);
return;
}