From 31198feec2ae77dd6673c42b42002871ddd02d37 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Mon, 10 Mar 2025 20:48:57 +0100 Subject: [PATCH] feat: add env variable to disable update check --- frontend/package-lock.json | 4 ++-- frontend/src/lib/services/app-config-service.ts | 4 ++-- frontend/src/lib/types/application-configuration.ts | 4 ++-- frontend/src/routes/settings/+layout.server.ts | 10 ++++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index f24c6907..52b5a101 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "pocket-id-frontend", - "version": "0.36.0", + "version": "0.37.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pocket-id-frontend", - "version": "0.36.0", + "version": "0.37.0", "dependencies": { "@simplewebauthn/browser": "^13.1.0", "@tailwindcss/vite": "^4.0.0", diff --git a/frontend/src/lib/services/app-config-service.ts b/frontend/src/lib/services/app-config-service.ts index 1039e7a2..66387872 100644 --- a/frontend/src/lib/services/app-config-service.ts +++ b/frontend/src/lib/services/app-config-service.ts @@ -63,8 +63,8 @@ export default class AppConfigService extends APIService { .then((res) => res.data) .catch(() => null); - let newestVersion: string | null = null; - let isUpToDate: boolean | null = null; + let newestVersion: string | undefined; + let isUpToDate: boolean | undefined; if (response) { newestVersion = response.tag_name.replace('v', ''); isUpToDate = newestVersion === currentVersion; diff --git a/frontend/src/lib/types/application-configuration.ts b/frontend/src/lib/types/application-configuration.ts index b6a8053f..37cbda34 100644 --- a/frontend/src/lib/types/application-configuration.ts +++ b/frontend/src/lib/types/application-configuration.ts @@ -45,7 +45,7 @@ export type AppConfigRawResponse = { }[]; export type AppVersionInformation = { - isUpToDate: boolean | null; - newestVersion: string | null; + isUpToDate?: boolean; + newestVersion?: string; currentVersion: string; }; diff --git a/frontend/src/routes/settings/+layout.server.ts b/frontend/src/routes/settings/+layout.server.ts index c50c44c0..cb437c5e 100644 --- a/frontend/src/routes/settings/+layout.server.ts +++ b/frontend/src/routes/settings/+layout.server.ts @@ -1,3 +1,5 @@ +import { version as currentVersion } from '$app/environment'; +import { env } from '$env/dynamic/private'; import AppConfigService from '$lib/services/app-config-service'; import type { AppVersionInformation } from '$lib/types/application-configuration'; import type { LayoutServerLoad } from './$types'; @@ -6,6 +8,14 @@ let versionInformation: AppVersionInformation; let versionInformationLastUpdated: number; export const load: LayoutServerLoad = async () => { + if (env.UPDATE_CHECK_DISABLED === 'true') { + return { + versionInformation: { + currentVersion: currentVersion + } satisfies AppVersionInformation + }; + } + const appConfigService = new AppConfigService(); // Cache the version information for 3 hours