Settings API for loader, preview branch select

This commit is contained in:
AAGaming
2022-08-24 23:51:20 -04:00
parent fe2b6b0283
commit 79db0c779d
8 changed files with 127 additions and 17 deletions
@@ -0,0 +1,33 @@
import { Dropdown, Field } from 'decky-frontend-lib';
import { FunctionComponent } from 'react';
import { useSetting } from '../../../../utils/hooks/useSetting';
enum UpdateBranch {
Stable,
Prerelease,
Nightly,
}
const BranchSelect: FunctionComponent<{}> = () => {
const [selectedBranch, setSelectedBranch] = useSetting<UpdateBranch>('branch', UpdateBranch.Prerelease);
return (
<Field label="Update Channel">
<Dropdown
rgOptions={Object.values(UpdateBranch)
.filter((branch) => typeof branch == 'string')
.map((branch) => ({
label: branch,
data: UpdateBranch[branch],
}))}
selectedOption={selectedBranch}
onChange={(newVal) => {
setSelectedBranch(newVal.data);
}}
/>
</Field>
);
};
export default BranchSelect;
@@ -1,15 +1,10 @@
import { Field, Toggle } from 'decky-frontend-lib';
import { useEffect, useState } from 'react';
import { FaBug } from 'react-icons/fa';
import { useSetting } from '../../../../utils/hooks/useSetting';
export default function RemoteDebuggingSettings() {
const [allowRemoteDebugging, setAllowRemoteDebugging] = useState<boolean>(false);
useEffect(() => {
(async () => {
const res = (await window.DeckyPluginLoader.callServerMethod('remote_debugging_allowed')) as { result: boolean };
setAllowRemoteDebugging(res.result);
})();
}, []);
const [allowRemoteDebugging, setAllowRemoteDebugging] = useSetting<boolean>('cef_forward', false);
return (
<Field
@@ -22,7 +17,7 @@ export default function RemoteDebuggingSettings() {
icon={<FaBug style={{ display: 'block' }} />}
>
<Toggle
value={allowRemoteDebugging}
value={allowRemoteDebugging || false}
onChange={(toggleValue) => {
setAllowRemoteDebugging(toggleValue);
if (toggleValue) window.DeckyPluginLoader.callServerMethod('allow_remote_debugging');
@@ -6,9 +6,10 @@ import { VerInfo, callUpdaterMethod, finishUpdate } from '../../../../updater';
import { useDeckyState } from '../../../DeckyState';
export default function UpdaterSettings() {
const { isLoaderUpdating, setIsLoaderUpdating } = useDeckyState();
const [versionInfo, setVersionInfo] = useState<VerInfo | null>(null);
const [checkingForUpdates, setCheckingForUpdates] = useState<boolean>(false);
const { isLoaderUpdating, setIsLoaderUpdating } = useDeckyState();
const [updateProgress, setUpdateProgress] = useState<number>(-1);
const [reloading, setReloading] = useState<boolean>(false);
@@ -3,6 +3,7 @@ import { useState } from 'react';
import { FaShapes } from 'react-icons/fa';
import { installFromURL } from '../../../../store';
import BranchSelect from './BranchSelect';
import RemoteDebuggingSettings from './RemoteDebugging';
import UpdaterSettings from './Updater';
@@ -21,6 +22,7 @@ export default function GeneralSettings() {
/>
</Field> */}
<UpdaterSettings />
<BranchSelect />
<RemoteDebuggingSettings />
<Field
label="Manual plugin install"