Handle already chosen Oculus as default download platform

This commit is contained in:
MathieuG-P
2023-12-17 13:39:48 +01:00
parent 01bc0e13e3
commit 14036b9269
3 changed files with 9 additions and 3 deletions
@@ -18,10 +18,15 @@ export function SettingRadioArray<T>({ id, items, selectedItemId, selectedItemVa
return item.id === selectedItemId || item.value === selectedItemValue;
}
const selectItem = (item: RadioItem<T>) => {
if(item.disabled){ return; }
onItemSelected?.(item);
}
return (
<div id={id} className="w-full flex gap-1.5" style={{flexDirection: direction}}>
{items.map(i => (
<div onClick={() => onItemSelected(i)} key={i.id} className={`py-3 w-full flex cursor-pointer justify-between items-center rounded-md px-2 transition-colors duration-200 ${isSelected(i) ? "bg-light-main-color-3 dark:bg-main-color-3" : "bg-light-main-color-1 dark:bg-main-color-1"} ${i.className}`}>
<div onClick={() => selectItem(i)} key={i.id} className={`py-3 w-full flex ${i.disabled ? "cursor-not-allowed" : "cursor-pointer"} ${i.disabled && "brightness-75"} justify-between items-center rounded-md px-2 transition-colors duration-200 ${isSelected(i) ? "bg-light-main-color-3 dark:bg-main-color-3" : "bg-light-main-color-1 dark:bg-main-color-1"} ${i.className}`}>
<div className="flex items-center">
<div className="h-5 rounded-full aspect-square border-2 border-gray-800 dark:border-white p-[3px] mr-2">
<motion.span initial={{ scale: 0 }} animate={{ scale: isSelected(i) ? 1 : 0 }} className="h-full w-full block bg-gray-800 dark:bg-white rounded-full" />
@@ -47,4 +52,5 @@ export interface RadioItem<T> {
textIcon?: string;
className?: string;
value?: T;
disabled?: boolean;
}
@@ -235,7 +235,7 @@ export function SettingsPage() {
<SettingContainer id="choose-default-store" minorTitle="pages.settings.steam-and-oculus.download-platform.title" description="pages.settings.steam-and-oculus.download-platform.desc" className="mt-3">
<SettingRadioArray items={[
{ id: 1, text: "Steam", value: BsStore.STEAM, icon: <SteamIcon className="h-6 w-6 float-left"/> },
{ id: 2, text: "Oculus Store (PC)", value: BsStore.OCULUS, icon: <OculusIcon className="h-6 w-6 float-left bg-white text-black rounded-full p-0.5"/>},
{ id: 2, text: "Oculus Store (PC)", value: BsStore.OCULUS, icon: <OculusIcon className="h-6 w-6 float-left bg-white text-black rounded-full p-0.5"/>, disabled: true},
{ id: 0, text: t("pages.settings.steam-and-oculus.download-platform.always-ask"), value: undefined, },
]} selectedItemValue={downloadStore} onItemSelected={handleChangeBsStore}/>
</SettingContainer>
@@ -75,7 +75,7 @@ export class BsDownloaderService extends AbstractBsDownloaderService {
public async downloadVersion(version: BSVersion, from?: BsStore): Promise<BSVersion> {
if(!from){
from = this.defaultStore ?? await this.chooseStoreToDownloadFrom();
from = this.defaultStore === BsStore.STEAM ? BsStore.STEAM : await this.chooseStoreToDownloadFrom();
}
return this.getStoreDownloader(from).downloadBsVersion(version).then(() => {