mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 08:32:03 +00:00
43b2269ea7
* Make version gray in plugin list * Settings/store icons together & plugin list fix * Navigation name/icon improvements * Decky settings overhaul and other fixes - Revert the tab icon to a plug - Rename DeckyFlat function to DeckyIcon - Add DialogBody to settings pages to improve scrolling - Add remote debugging settings to the developer settings - Fix React devtools interactions to work more easily - Add spacing to React devtools description - Specify Decky vs. plugin store - Compact version information by update button - Add current version to bottom of settings - Remove unnecessary settings icons - Change CEF debugger icon to Chrome (bug icon too generic, is Chromium) - Make buttons/dropdowns in settings have fixed width - Make download icon act/appear similar to Valve's for Deck * Final UI adjustments * Switch plugin settings icon to plug
166 lines
5.5 KiB
TypeScript
166 lines
5.5 KiB
TypeScript
import {
|
|
Carousel,
|
|
DialogButton,
|
|
Field,
|
|
FocusRing,
|
|
Focusable,
|
|
ProgressBarWithInfo,
|
|
Spinner,
|
|
showModal,
|
|
} from 'decky-frontend-lib';
|
|
import { useCallback } from 'react';
|
|
import { Suspense, lazy } from 'react';
|
|
import { useEffect, useState } from 'react';
|
|
import { FaExclamation } from 'react-icons/fa';
|
|
|
|
import { VerInfo, callUpdaterMethod, finishUpdate } from '../../../../updater';
|
|
import { findSP } from '../../../../utils/windows';
|
|
import { useDeckyState } from '../../../DeckyState';
|
|
import InlinePatchNotes from '../../../patchnotes/InlinePatchNotes';
|
|
import WithSuspense from '../../../WithSuspense';
|
|
|
|
const MarkdownRenderer = lazy(() => import('../../../Markdown'));
|
|
|
|
function PatchNotesModal({ versionInfo, closeModal }: { versionInfo: VerInfo | null; closeModal?: () => {} }) {
|
|
const SP = findSP();
|
|
return (
|
|
<Focusable onCancelButton={closeModal}>
|
|
<FocusRing>
|
|
<Carousel
|
|
fnItemRenderer={(id: number) => (
|
|
<Focusable
|
|
style={{
|
|
marginTop: '40px',
|
|
height: 'calc( 100% - 40px )',
|
|
overflowY: 'scroll',
|
|
display: 'flex',
|
|
justifyContent: 'center',
|
|
margin: '40px',
|
|
}}
|
|
>
|
|
<div>
|
|
<h1>{versionInfo?.all?.[id]?.name}</h1>
|
|
{versionInfo?.all?.[id]?.body ? (
|
|
<WithSuspense>
|
|
<MarkdownRenderer onDismiss={closeModal}>{versionInfo.all[id].body}</MarkdownRenderer>
|
|
</WithSuspense>
|
|
) : (
|
|
'no patch notes for this version'
|
|
)}
|
|
</div>
|
|
</Focusable>
|
|
)}
|
|
fnGetId={(id) => id}
|
|
nNumItems={versionInfo?.all?.length}
|
|
nHeight={SP.innerHeight - 40}
|
|
nItemHeight={SP.innerHeight - 40}
|
|
nItemMarginX={0}
|
|
initialColumn={0}
|
|
autoFocus={true}
|
|
fnGetColumnWidth={() => SP.innerWidth}
|
|
name="Decky Updates"
|
|
/>
|
|
</FocusRing>
|
|
</Focusable>
|
|
);
|
|
}
|
|
|
|
export default function UpdaterSettings() {
|
|
const { isLoaderUpdating, setIsLoaderUpdating, versionInfo, setVersionInfo } = useDeckyState();
|
|
|
|
const [checkingForUpdates, setCheckingForUpdates] = useState<boolean>(false);
|
|
const [updateProgress, setUpdateProgress] = useState<number>(-1);
|
|
const [reloading, setReloading] = useState<boolean>(false);
|
|
|
|
useEffect(() => {
|
|
window.DeckyUpdater = {
|
|
updateProgress: (i) => {
|
|
setUpdateProgress(i);
|
|
setIsLoaderUpdating(true);
|
|
},
|
|
finish: async () => {
|
|
setUpdateProgress(0);
|
|
setReloading(true);
|
|
await finishUpdate();
|
|
},
|
|
};
|
|
}, []);
|
|
|
|
const showPatchNotes = useCallback(() => {
|
|
showModal(<PatchNotesModal versionInfo={versionInfo} />);
|
|
}, [versionInfo]);
|
|
|
|
return (
|
|
<>
|
|
<Field
|
|
onOptionsActionDescription={versionInfo?.all ? 'Patch Notes' : undefined}
|
|
onOptionsButton={versionInfo?.all ? showPatchNotes : undefined}
|
|
label="Decky Updates"
|
|
description={
|
|
checkingForUpdates || versionInfo?.remote?.tag_name != versionInfo?.current || !versionInfo?.remote ? (
|
|
''
|
|
) : (
|
|
<span>Up to date: running {versionInfo?.current}</span>
|
|
)
|
|
}
|
|
icon={
|
|
versionInfo?.remote &&
|
|
versionInfo?.remote?.tag_name != versionInfo?.current && (
|
|
<FaExclamation color="var(--gpColor-Yellow)" style={{ display: 'block' }} />
|
|
)
|
|
}
|
|
childrenContainerWidth={'fixed'}
|
|
>
|
|
{updateProgress == -1 && !isLoaderUpdating ? (
|
|
<DialogButton
|
|
disabled={!versionInfo?.updatable || checkingForUpdates}
|
|
onClick={
|
|
!versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
|
|
? async () => {
|
|
setCheckingForUpdates(true);
|
|
const res = (await callUpdaterMethod('check_for_updates')) as { result: VerInfo };
|
|
setVersionInfo(res.result);
|
|
setCheckingForUpdates(false);
|
|
}
|
|
: async () => {
|
|
setUpdateProgress(0);
|
|
callUpdaterMethod('do_update');
|
|
}
|
|
}
|
|
>
|
|
{checkingForUpdates
|
|
? 'Checking'
|
|
: !versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
|
|
? 'Check For Updates'
|
|
: 'Install Update'}
|
|
</DialogButton>
|
|
) : (
|
|
<ProgressBarWithInfo
|
|
layout="inline"
|
|
bottomSeparator="none"
|
|
nProgress={updateProgress}
|
|
indeterminate={reloading}
|
|
sOperationText={reloading ? 'Reloading' : 'Updating'}
|
|
/>
|
|
)}
|
|
</Field>
|
|
{versionInfo?.remote && versionInfo?.remote?.tag_name != versionInfo?.current && (
|
|
<InlinePatchNotes
|
|
title={versionInfo?.remote.name}
|
|
date={new Intl.RelativeTimeFormat('en-US', {
|
|
numeric: 'auto',
|
|
}).format(
|
|
Math.ceil((new Date(versionInfo.remote.published_at).getTime() - new Date().getTime()) / 86400000),
|
|
'day',
|
|
)}
|
|
onClick={showPatchNotes}
|
|
>
|
|
<Suspense fallback={<Spinner style={{ width: '24', height: '24' }} />}>
|
|
<MarkdownRenderer>{versionInfo?.remote.body}</MarkdownRenderer>
|
|
</Suspense>
|
|
</InlinePatchNotes>
|
|
)}
|
|
</>
|
|
);
|
|
}
|