forked from external-repos/LifeTrinket
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f94103fe51 | ||
|
|
c36668b933 | ||
|
|
f9d0346300 | ||
|
|
2f3ee74c74 | ||
|
|
f8f0788b97 | ||
|
|
bfe25eacb7 | ||
|
|
7b0965c0dd |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "life-trinket",
|
||||
"private": true,
|
||||
"version": "0.5.4",
|
||||
"version": "0.5.43",
|
||||
"type": "commonjs",
|
||||
"engines": {
|
||||
"node": ">=18",
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useGlobalSettings } from '../../Hooks/useGlobalSettings';
|
||||
import { ModalWrapper } from './InfoModal';
|
||||
import { Separator } from './Separator';
|
||||
import { Paragraph } from './TextComponents';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
const SettingContainer = twc.div`w-full flex flex-col`;
|
||||
|
||||
@@ -22,7 +22,7 @@ type SettingsModalProps = {
|
||||
export const SettingsModal = ({ isOpen, closeModal }: SettingsModalProps) => {
|
||||
const { settings, setSettings, isPWA } = useGlobalSettings();
|
||||
const [isLatestVersion, setIsLatestVersion] = useState(false);
|
||||
const newVersion = useRef<string | undefined>(undefined);
|
||||
const [newVersion, setNewVersion] = useState<string | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen) {
|
||||
@@ -43,18 +43,22 @@ export const SettingsModal = ({ isOpen, closeModal }: SettingsModalProps) => {
|
||||
);
|
||||
const data = await result.json();
|
||||
|
||||
console.info('liveVersion', data.name);
|
||||
|
||||
if (!data.name) {
|
||||
setNewVersion(undefined);
|
||||
setIsLatestVersion(false);
|
||||
newVersion.current = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
setNewVersion(data.name);
|
||||
|
||||
/* @ts-expect-error is defined in vite.config.ts*/
|
||||
if (data.name === APP_VERSION) {
|
||||
newVersion.current = data.name;
|
||||
setIsLatestVersion(true);
|
||||
return;
|
||||
}
|
||||
|
||||
setIsLatestVersion(false);
|
||||
} catch (error) {
|
||||
console.error('error getting latest version string', error);
|
||||
@@ -147,13 +151,13 @@ export const SettingsModal = ({ isOpen, closeModal }: SettingsModalProps) => {
|
||||
<span className="text-sm text-text-secondary">(latest)</span>
|
||||
)}
|
||||
</Paragraph>
|
||||
{!isLatestVersion && newVersion.current && (
|
||||
{!isLatestVersion && newVersion && (
|
||||
<Paragraph className="text-text-secondary text-lg text-center">
|
||||
New version ({newVersion.current}) is available!{' '}
|
||||
New version ({newVersion}) is available!{' '}
|
||||
</Paragraph>
|
||||
)}
|
||||
</SettingContainer>
|
||||
{!isLatestVersion && newVersion.current && (
|
||||
{!isLatestVersion && newVersion && (
|
||||
<Button
|
||||
variant="contained"
|
||||
style={{ marginTop: '0.25rem', marginBottom: '0.25rem' }}
|
||||
|
||||
Reference in New Issue
Block a user