diff options
| author | TrainDoctor <traindoctor@protonmail.com> | 2022-10-29 15:03:12 -0700 |
|---|---|---|
| committer | TrainDoctor <traindoctor@protonmail.com> | 2022-10-29 15:03:21 -0700 |
| commit | 4d30339c34782a6e3d313804fa393c95ad38c4b2 (patch) | |
| tree | cdeb7463f3237f2dd998d51f2fa5b39f67ded196 /frontend/src/store.tsx | |
| parent | 5996a3f88be51e5ac59256b2d078fa6172639fb4 (diff) | |
| download | decky-loader-4d30339c34782a6e3d313804fa393c95ad38c4b2.tar.gz decky-loader-4d30339c34782a6e3d313804fa393c95ad38c4b2.zip | |
Add StoreSelect component
Diffstat (limited to 'frontend/src/store.tsx')
| -rw-r--r-- | frontend/src/store.tsx | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/frontend/src/store.tsx b/frontend/src/store.tsx index cc0e4cf0..9b1c5d2e 100644 --- a/frontend/src/store.tsx +++ b/frontend/src/store.tsx @@ -1,4 +1,11 @@ import { Plugin } from './plugin'; +import { getSetting, setSetting } from './utils/settings'; + +export enum Store { + Default, + Testing, + Custom, +} export interface StorePluginVersion { name: string; @@ -20,12 +27,41 @@ export type PluginUpdateMapping = Map<string, StorePluginVersion>; export async function getPluginList(): Promise<StorePlugin[]> { let version = await window.DeckyPluginLoader.updateVersion(); - return fetch('https://plugins.deckbrew.xyz/plugins', { - method: 'GET', - headers: { - 'X-Decky-Version': version.current, - }, - }).then((r) => r.json()); + 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', { + method: 'GET', + headers: { + 'X-Decky-Version': version.current, + }, + }).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) { |
