Small ui fixes on firmware updates (#1291)

This commit is contained in:
lucas lelievre authored and GitHub committed 2025-01-31 13:54:26 +01:00
1 parent 15ea04d7c9
commit fb23ba8522
5 files changed
+23 -8

No files matched your search

+1
View File
@@ -1276,6 +1276,7 @@ firmware_update-changelog-title = Updating to {$version}
firmware_update-looking_for_devices = Looking for devices to update...
firmware_update-retry = Retry
firmware_update-update = Update Selected Trackers
firmware_update-exit = Exit
## Tray Menu
tray_menu-show = Show
@@ -300,13 +300,21 @@ export function FirmwareUpdate() {
queueFlashing(selectedDevices);
};
const exit = () => {
clear();
navigate('/');
};
const canStartUpdate =
isValid &&
devices.length !== 0 &&
!hasPendingTrackers &&
trackerWithErrors.length === 0;
const canRetry =
isValid && devices.length !== 0 && trackerWithErrors.length !== 0;
!hasPendingTrackers &&
isValid &&
devices.length !== 0 &&
trackerWithErrors.length !== 0;
const statusKeys = Object.keys(status);
@@ -395,6 +403,13 @@ export function FirmwareUpdate() {
onClick={startUpdate}
></Button>
</Localized>
<Localized id="firmware_update-exit">
<Button
variant="primary"
onClick={exit}
disabled={hasPendingTrackers}
></Button>
</Localized>
</div>
</div>
</div>
@@ -141,7 +141,6 @@ export function TrackerCard({
}) {
const { currentFirmwareRelease } = useAppContext();
const { useVelocity } = useTracker(tracker);
const velocity = useVelocity();
return (
+4 -4
View File
@@ -130,14 +130,14 @@ export function useProvideAppContext(): AppContext {
useEffect(() => {
const fetchCurrentFirmwareRelease = async () => {
const releases: any[] | null = JSON.parse(
await cacheWrap(
(await cacheWrap(
'firmware-releases',
() =>
fetch('https://api.github.com/repos/SlimeVR/SlimeVR-Tracker-ESP/releases')
.then((res) => res.text())
.catch(() => 'null'),
1000 * 60 * 60
)
.catch(() => null),
60 * 60 * 1000
)) ?? 'null'
);
if (!releases) return null;
+2 -2
View File
@@ -30,7 +30,7 @@ export async function cacheGet(key: string): Promise<string | null> {
const item = JSON.parse(itemStr);
const now = new Date();
if (now.getTime() > item.expiry) {
if (item.expiry > 0 && now.getTime() > item.expiry) {
await store.delete(key);
return null;
}
@@ -50,7 +50,7 @@ export async function cacheSet(key: string, value: unknown, ttl: number | undefi
export async function cacheWrap(
key: string,
orDefault: () => Promise<string>,
orDefault: () => Promise<string | null>,
ttl: number | undefined
) {
const realItem = await store.get(key);