diff --git a/backend/check-version.ts b/backend/check-version.ts
index acfb5fb..cd6508a 100644
--- a/backend/check-version.ts
+++ b/backend/check-version.ts
@@ -3,69 +3,55 @@ import compareVersions from "compare-versions";
import packageJSON from "../package.json";
import { Settings } from "./settings";
-export const obj = {
- version: packageJSON.version,
- latestVersion: null,
-};
-export default obj;
-
// How much time in ms to wait between update checks
const UPDATE_CHECKER_INTERVAL_MS = 1000 * 60 * 60 * 48;
const CHECK_URL = "https://dockge.kuma.pet/version";
-let interval : NodeJS.Timeout;
+class CheckVersion {
+ version = packageJSON.version;
+ latestVersion? : string;
+ interval? : NodeJS.Timeout;
-export function startInterval() {
- const check = async () => {
- if (await Settings.get("checkUpdate") === false) {
- return;
- }
-
- log.debug("update-checker", "Retrieving latest versions");
-
- try {
- const res = await fetch(CHECK_URL);
- const data = await res.json();
-
- // For debug
- if (process.env.TEST_CHECK_VERSION === "1") {
- data.slow = "1000.0.0";
+ async startInterval() {
+ const check = async () => {
+ if (await Settings.get("checkUpdate") === false) {
+ return;
}
- const checkBeta = await Settings.get("checkBeta");
+ log.debug("update-checker", "Retrieving latest versions");
- if (checkBeta && data.beta) {
- if (compareVersions.compare(data.beta, data.slow, ">")) {
- obj.latestVersion = data.beta;
- return;
+ try {
+ const res = await fetch(CHECK_URL);
+ const data = await res.json();
+
+ // For debug
+ if (process.env.TEST_CHECK_VERSION === "1") {
+ data.slow = "1000.0.0";
}
+
+ const checkBeta = await Settings.get("checkBeta");
+
+ if (checkBeta && data.beta) {
+ if (compareVersions.compare(data.beta, data.slow, ">")) {
+ this.latestVersion = data.beta;
+ return;
+ }
+ }
+
+ if (data.slow) {
+ this.latestVersion = data.slow;
+ }
+
+ } catch (_) {
+ log.info("update-checker", "Failed to check for new versions");
}
- if (data.slow) {
- obj.latestVersion = data.slow;
- }
+ };
- } catch (_) {
- log.info("update-checker", "Failed to check for new versions");
- }
-
- };
-
- check();
- interval = setInterval(check, UPDATE_CHECKER_INTERVAL_MS);
-}
-
-/**
- * Enable the check update feature
- * @param value Should the check update feature be enabled?
- * @returns
- */
-export async function enableCheckUpdate(value : boolean) {
- await Settings.set("checkUpdate", value);
-
- clearInterval(interval);
-
- if (value) {
- startInterval();
+ await check();
+ this.interval = setInterval(check, UPDATE_CHECKER_INTERVAL_MS);
}
}
+
+const checkVersion = new CheckVersion();
+export default checkVersion;
diff --git a/backend/dockge-server.ts b/backend/dockge-server.ts
index 93061f3..da0d3fb 100644
--- a/backend/dockge-server.ts
+++ b/backend/dockge-server.ts
@@ -308,6 +308,7 @@ export class DockgeServer {
this.sendStackList(true);
});
+ checkVersion.startInterval();
});
gracefulShutdown(this.httpServer, {
diff --git a/frontend/src/lang/en.json b/frontend/src/lang/en.json
index f029201..c30b92c 100644
--- a/frontend/src/lang/en.json
+++ b/frontend/src/lang/en.json
@@ -98,5 +98,6 @@
"reconnecting...": "Reconnecting…",
"connecting...": "Connecting to the socket server…",
"url": "URL | URLs",
- "extra": "Extra"
+ "extra": "Extra",
+ "newUpdate": "New Update"
}
diff --git a/frontend/src/layouts/Layout.vue b/frontend/src/layouts/Layout.vue
index ae0d8ae..ef793c7 100644
--- a/frontend/src/layouts/Layout.vue
+++ b/frontend/src/layouts/Layout.vue
@@ -16,8 +16,8 @@
Dockge
-
-