mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 22:31:59 +00:00
Add StoreSelect component
This commit is contained in:
@@ -10,7 +10,7 @@ const logger = new Logger('BranchSelect');
|
|||||||
enum UpdateBranch {
|
enum UpdateBranch {
|
||||||
Stable,
|
Stable,
|
||||||
Prerelease,
|
Prerelease,
|
||||||
// Nightly,
|
Testing,
|
||||||
}
|
}
|
||||||
|
|
||||||
const BranchSelect: FunctionComponent<{}> = () => {
|
const BranchSelect: FunctionComponent<{}> = () => {
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { Dropdown, Field, TextField } from 'decky-frontend-lib';
|
||||||
|
import { FunctionComponent } from 'react';
|
||||||
|
import { FaShapes } from 'react-icons/fa';
|
||||||
|
|
||||||
|
import Logger from '../../../../logger';
|
||||||
|
import { Store } from '../../../../store';
|
||||||
|
import { useSetting } from '../../../../utils/hooks/useSetting';
|
||||||
|
|
||||||
|
const logger = new Logger('StoreSelect');
|
||||||
|
|
||||||
|
const StoreSelect: FunctionComponent<{}> = () => {
|
||||||
|
const [selectedStore, setSelectedStore] = useSetting<Store>('store', Store.Default);
|
||||||
|
const [selectedStoreURL, setSelectedStoreURL] = useSetting<string | null>('store-url', null);
|
||||||
|
|
||||||
|
// Returns numerical values from 0 to 2 (with current branch setup as of 8/28/22)
|
||||||
|
// 0 being Default, 1 being Testing and 2 being Custom
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Field label="Store Channel">
|
||||||
|
<Dropdown
|
||||||
|
rgOptions={Object.values(Store)
|
||||||
|
.filter((store) => typeof store == 'string')
|
||||||
|
.map((store) => ({
|
||||||
|
label: store,
|
||||||
|
data: Store[store],
|
||||||
|
}))}
|
||||||
|
selectedOption={selectedStore}
|
||||||
|
onChange={async (newVal) => {
|
||||||
|
await setSelectedStore(newVal.data);
|
||||||
|
logger.log('switching stores!');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
{selectedStore == Store.Custom && (
|
||||||
|
<Field
|
||||||
|
label="Custom Store"
|
||||||
|
indentLevel={1}
|
||||||
|
description={
|
||||||
|
<TextField
|
||||||
|
label={'URL'}
|
||||||
|
value={selectedStoreURL || undefined}
|
||||||
|
onChange={(e) => setSelectedStoreURL(e?.target.value || null)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
icon={<FaShapes style={{ display: 'block' }} />}
|
||||||
|
></Field>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default StoreSelect;
|
||||||
@@ -5,6 +5,7 @@ import { FaShapes, FaTools } from 'react-icons/fa';
|
|||||||
import { installFromURL } from '../../../../store';
|
import { installFromURL } from '../../../../store';
|
||||||
import BranchSelect from './BranchSelect';
|
import BranchSelect from './BranchSelect';
|
||||||
import RemoteDebuggingSettings from './RemoteDebugging';
|
import RemoteDebuggingSettings from './RemoteDebugging';
|
||||||
|
import StoreSelect from './StoreSelect';
|
||||||
import UpdaterSettings from './Updater';
|
import UpdaterSettings from './Updater';
|
||||||
|
|
||||||
export default function GeneralSettings({
|
export default function GeneralSettings({
|
||||||
@@ -15,10 +16,12 @@ export default function GeneralSettings({
|
|||||||
setIsDeveloper: (val: boolean) => void;
|
setIsDeveloper: (val: boolean) => void;
|
||||||
}) {
|
}) {
|
||||||
const [pluginURL, setPluginURL] = useState('');
|
const [pluginURL, setPluginURL] = useState('');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<UpdaterSettings />
|
<UpdaterSettings />
|
||||||
<BranchSelect />
|
<BranchSelect />
|
||||||
|
<StoreSelect />
|
||||||
<RemoteDebuggingSettings />
|
<RemoteDebuggingSettings />
|
||||||
<Field
|
<Field
|
||||||
label="Developer mode"
|
label="Developer mode"
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
import { Plugin } from './plugin';
|
import { Plugin } from './plugin';
|
||||||
|
import { getSetting, setSetting } from './utils/settings';
|
||||||
|
|
||||||
|
export enum Store {
|
||||||
|
Default,
|
||||||
|
Testing,
|
||||||
|
Custom,
|
||||||
|
}
|
||||||
|
|
||||||
export interface StorePluginVersion {
|
export interface StorePluginVersion {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -20,12 +27,41 @@ export type PluginUpdateMapping = Map<string, StorePluginVersion>;
|
|||||||
|
|
||||||
export async function getPluginList(): Promise<StorePlugin[]> {
|
export async function getPluginList(): Promise<StorePlugin[]> {
|
||||||
let version = await window.DeckyPluginLoader.updateVersion();
|
let version = await window.DeckyPluginLoader.updateVersion();
|
||||||
|
let store = await getSetting<Store>('store', Store.Default);
|
||||||
|
let customURL = await getSetting<string>('store-url', 'https://plugins.deckbrew.xyz/plugins');
|
||||||
|
let storeURL;
|
||||||
|
if (!store) {
|
||||||
|
console.log('Could not get a default store, using Default.');
|
||||||
|
await setSetting('store-url', Store.Default);
|
||||||
return fetch('https://plugins.deckbrew.xyz/plugins', {
|
return fetch('https://plugins.deckbrew.xyz/plugins', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'X-Decky-Version': version.current,
|
'X-Decky-Version': version.current,
|
||||||
},
|
},
|
||||||
}).then((r) => r.json());
|
}).then((r) => r.json());
|
||||||
|
} else {
|
||||||
|
switch (+store) {
|
||||||
|
case Store.Default:
|
||||||
|
storeURL = 'https://plugins.deckbrew.xyz/plugins';
|
||||||
|
break;
|
||||||
|
case Store.Testing:
|
||||||
|
storeURL = 'https://testing.deckbrew.xyz/plugins';
|
||||||
|
break;
|
||||||
|
case Store.Custom:
|
||||||
|
storeURL = customURL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.error('Somehow you ended up without a standard URL, using the default URL.');
|
||||||
|
storeURL = 'https://plugins.deckbrew.xyz/plugins';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return fetch(storeURL, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'X-Decky-Version': version.current,
|
||||||
|
},
|
||||||
|
}).then((r) => r.json());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function installFromURL(url: string) {
|
export async function installFromURL(url: string) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export enum Branches {
|
export enum Branches {
|
||||||
Release,
|
Release,
|
||||||
Prerelease,
|
Prerelease,
|
||||||
Nightly,
|
Testing,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeckyUpdater {
|
export interface DeckyUpdater {
|
||||||
|
|||||||
Reference in New Issue
Block a user