From b1307993abde4164b1939e4a2cd05aa24b6085f2 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sun, 10 Oct 2021 02:53:14 -0700 Subject: [PATCH] Add version check in config page --- src/components/settings/Config.tsx | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/components/settings/Config.tsx b/src/components/settings/Config.tsx index 2fba579..6f9ae23 100644 --- a/src/components/settings/Config.tsx +++ b/src/components/settings/Config.tsx @@ -1,4 +1,6 @@ import React, { useEffect, useState } from 'react'; +import axios from 'axios'; +import { shell } from 'electron'; import { Button, Whisper, Popover, Nav, ButtonToolbar } from 'rsuite'; import { startScan, getScanStatus } from '../../api/api'; import GenericPage from '../layout/GenericPage'; @@ -12,12 +14,25 @@ import PlayerConfig from './ConfigPanels/PlayerConfig'; import CacheConfig from './ConfigPanels/CacheConfig'; import DebugConfig from './ConfigPanels/DebugConfig'; import useRouterQuery from '../../hooks/useRouterQuery'; +import packageJson from '../../package.json'; + +const GITHUB_RELEASE_URL = 'https://api.github.com/repos/jeffvli/sonixd/releases?per_page=3'; const Config = () => { const [isScanning, setIsScanning] = useState(false); const [scanProgress, setScanProgress] = useState(0); const query = useRouterQuery(); const [page, setPage] = useState(query.get('page') || 'playback'); + const [latestRelease, setLatestRelease] = useState(packageJson.version); + + useEffect(() => { + const fetchReleases = async () => { + const releases = await axios.get(GITHUB_RELEASE_URL); + setLatestRelease(releases.data[0]?.name); + }; + + fetchReleases(); + }, []); useEffect(() => { // Check scan status on render @@ -105,6 +120,54 @@ const Config = () => { > Reset defaults + + <> + Current version: {packageJson.version} +
+ Latest version: {latestRelease} +
+ Node: {process.versions.node} +
+ Chrome: {process.versions.chrome} +
+ Electron: {process.versions.electron} + shell.openExternal('https://github.com/jeffvli/sonixd')} + > + View on GitHub + + + shell.openExternal( + 'https://github.com/jeffvli/sonixd/blob/main/CHANGELOG.md' + ) + } + > + View CHANGELOG + + + + } + > + + v{packageJson.version} + +
} />