From 5b977790b052e883033efa101e0f047800855ca0 Mon Sep 17 00:00:00 2001
From: Fabian Posenau
Date: Sat, 4 Mar 2023 22:40:19 +0100
Subject: [PATCH] Feat/update check (#303)
* feat: show latest version in settings modal
---------
Co-authored-by: Fabian Posenau
---
apps/client/src/common/api/apiConstants.ts | 3 +
apps/client/src/common/api/ontimeApi.ts | 11 +++-
.../src/features/modals/AppSettingsModal.jsx | 61 +++++++++++++------
3 files changed, 57 insertions(+), 18 deletions(-)
diff --git a/apps/client/src/common/api/apiConstants.ts b/apps/client/src/common/api/apiConstants.ts
index 287e4d800..070e4a0f3 100644
--- a/apps/client/src/common/api/apiConstants.ts
+++ b/apps/client/src/common/api/apiConstants.ts
@@ -19,6 +19,9 @@ export const FEAT_PLAYBACKCONTROL = 'feat-playbackcontrol';
export const FEAT_RUNDOWN = 'feat-rundown';
export const TIMER = 'timer';
+// external stuff
+export const githubURL = 'https://api.github.com/repos/cpvalente/ontime/releases/latest';
+
/**
* @description finds server path given the current location, it
* @return {*}
diff --git a/apps/client/src/common/api/ontimeApi.ts b/apps/client/src/common/api/ontimeApi.ts
index 9f90da5d0..9c0b3fa11 100644
--- a/apps/client/src/common/api/ontimeApi.ts
+++ b/apps/client/src/common/api/ontimeApi.ts
@@ -3,7 +3,7 @@ import { Alias, OSCSettings, Settings, UserFields, ViewSettings } from 'ontime-t
import { InfoType } from '../models/Info';
-import { ontimeURL } from './apiConstants';
+import { githubURL, ontimeURL } from './apiConstants';
/**
* @description HTTP request to retrieve application settings
@@ -151,3 +151,12 @@ export const uploadData = async (file: string, setProgress: (value: number) => v
})
.then((response) => response.data.id);
};
+
+/**
+ * @description HTTP request to get the latest version and url from github
+ * @return {Promise}
+ */
+export async function getLatestVersion(): Promise
- {`Running ontime version ${version}`}
);