fix logical error when no store was set

This commit is contained in:
Party Wumpus
2023-10-17 13:44:44 +01:00
committed by marios8543
parent 944e0e6e07
commit 2cdb49168c
+26 -32
View File
@@ -38,40 +38,34 @@ export async function getStore(): Promise<Store> {
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 store = await getSetting<Store>('store', null);
let customURL = await getSetting<string>('store-url', 'https://plugins.deckbrew.xyz/plugins'); let customURL = await getSetting<string>('store-url', 'https://plugins.deckbrew.xyz/plugins');
let storeURL; let storeURL;
if (!store) { if (store === null) {
console.log('Could not get a default store, using Default.'); console.log('Could not get store, using Default.');
await setSetting('store-url', Store.Default); await setSetting('store', Store.Default);
return fetch('https://plugins.deckbrew.xyz/plugins', { store = Store.Default
method: 'GET', }
headers: { switch (+store) {
'X-Decky-Version': version.current, case Store.Default:
}, storeURL = 'https://plugins.deckbrew.xyz/plugins';
}).then((r) => r.json()); break;
} else { case Store.Testing:
switch (+store) { storeURL = 'https://testing.deckbrew.xyz/plugins';
case Store.Default: break;
storeURL = 'https://plugins.deckbrew.xyz/plugins'; case Store.Custom:
break; storeURL = customURL;
case Store.Testing: break;
storeURL = 'https://testing.deckbrew.xyz/plugins'; default:
break; console.error('Somehow you ended up without a standard URL, using the default URL.');
case Store.Custom: storeURL = 'https://plugins.deckbrew.xyz/plugins';
storeURL = customURL; break;
break; return fetch(storeURL, {
default: method: 'GET',
console.error('Somehow you ended up without a standard URL, using the default URL.'); headers: {
storeURL = 'https://plugins.deckbrew.xyz/plugins'; 'X-Decky-Version': version.current,
break; },
} }).then((r) => r.json());
return fetch(storeURL, {
method: 'GET',
headers: {
'X-Decky-Version': version.current,
},
}).then((r) => r.json());
} }
} }