From 7d31c51790384e38176292a6bac792b6f4b378b4 Mon Sep 17 00:00:00 2001
From: "Arthur E. Jones" <PartyLich@gmail.com>
Date: Fri, 1 Jul 2022 22:12:04 -0500
Subject: [PATCH] feat: display server version on settings page

Shows the version returned form the server /info endpoint as static text
on the Settings component.
---
 .../desktop-client/src/components/Settings.js | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/packages/desktop-client/src/components/Settings.js b/packages/desktop-client/src/components/Settings.js
index 11aa9494f..c17f0d70d 100644
--- a/packages/desktop-client/src/components/Settings.js
+++ b/packages/desktop-client/src/components/Settings.js
@@ -474,6 +474,23 @@ function SettingsLink({ to, name, style, first, last }) {
 }
 
 function Version() {
+  let [version, setVersion] = useState('');
+
+  useEffect(async () => {
+    const url = await send('get-server-url');
+    if (!url || url.indexOf('not-configured') !== -1) return;
+
+    try {
+      const res = await fetch(url + '/info');
+      if (!res.ok) return;
+
+      const info = await res.json();
+      setVersion((info && info.build.version) || '');
+    } catch (e) {
+      setVersion('');
+    }
+  }, []);
+
   return (
     <Text
       style={[
@@ -487,7 +504,7 @@ function Version() {
         styles.smallText
       ]}
     >
-      v{window.Actual.ACTUAL_VERSION}
+      v{window.Actual.ACTUAL_VERSION} | {version ? `v${version}` : 'N/A'}
     </Text>
   );
 }
-- 
GitLab