Skip to content

Commit

Permalink
chore: finishing touches
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsmaerten committed Feb 11, 2024
1 parent 7f0a13a commit 2a5c3ad
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "glucose-ticker",
"productName": "Glucose Ticker",
"version": "1.0.4",
"version": "1.0.5-alpha",
"description": "Live blood sugar on the Windows Taskbar",
"main": "tmp/dist/index.js",
"scripts": {
Expand All @@ -18,6 +18,10 @@
"name": "Niels Maerten",
"url": "https://github.com/nielsmaerten"
},
"repository": {
"type": "git",
"url": "https://github.com/nielsmaerten/glucose-ticker"
},
"license": "MIT",
"dependencies": {
"axios": "^0.27.0",
Expand Down
48 changes: 41 additions & 7 deletions src/web-app/components/Splash.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import React, { useEffect } from "react";
import * as storage from "idb-keyval";
import { version } from "../../../package.json";
import { version, repository } from "../../../package.json";
import { STORAGE_KEY, AppSettings, DONATE_LINK } from "../../shared/constants";

export default (props: any) => {
Expand All @@ -17,19 +17,51 @@ export default (props: any) => {
require("electron").shell.openExternal(DONATE_LINK);
};

const getTimeLeft = (): string => {
const { seconds } = props;
return `${seconds} ${seconds === 1 ? "second" : "seconds"}`;
const onVersionClick = (e: any) => {
e.preventDefault();
require("electron").shell.openExternal(repository.url + "/releases");
};

const getTimeLeft = (props: any): string => {
const { s } = props;
return `${s} ${s === 1 ? "second" : "seconds"}`;
};

const getLatestVersion = async () => {
const response = await fetch(
"https://api.github.com/repos/nielsmaerten/glucose-ticker/releases/latest"
);
const data = await response.json();
return data.tag_name;
}

const showVersionTag = () => {
const aLatestVersion = <a href="#" onClick={onVersionClick}>{latestVersion}</a>;
return (
<p>
<small>
v{version}
{latestVersion !== version && <strong> (latest: {aLatestVersion})</strong>}
</small>
</p>
);
}

useEffect(() => {
getLatestVersion().then(setLatestVersion);
});

const [latestVersion, setLatestVersion] = React.useState(version);


return (
<div>
<h2>Nightscout will be here in {getTimeLeft()}</h2>
<h2>Nightscout will be here in {getTimeLeft(props)}</h2>
<hr />
<p>Need to change your settings? Click the button below:</p>
<button onClick={resetSettings}>Open settings</button>
<p>
<hr />
<p>
If you find Glucose Ticker useful, consider supporting my work with a
coffee 😊
</p>
Expand All @@ -41,6 +73,8 @@ export default (props: any) => {
alt="Buy Me a Coffee at ko-fi.com"
/>
</a>
<hr />
{showVersionTag()}
</div>
);
};

0 comments on commit 2a5c3ad

Please sign in to comment.