From 14036b9269284fc1aa188ea7337de9dc96181db2 Mon Sep 17 00:00:00 2001 From: MathieuG-P <40181755+Zagrios@users.noreply.github.com> Date: Sun, 17 Dec 2023 13:39:48 +0100 Subject: [PATCH] Handle already chosen Oculus as default download platform --- .../components/settings/setting-radio-array.component.tsx | 8 +++++++- src/renderer/pages/settings-page.component.tsx | 2 +- .../services/bs-version-download/bs-downloader.service.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/settings/setting-radio-array.component.tsx b/src/renderer/components/settings/setting-radio-array.component.tsx index 60eb44a1..c6607760 100644 --- a/src/renderer/components/settings/setting-radio-array.component.tsx +++ b/src/renderer/components/settings/setting-radio-array.component.tsx @@ -18,10 +18,15 @@ export function SettingRadioArray({ id, items, selectedItemId, selectedItemVa return item.id === selectedItemId || item.value === selectedItemValue; } + const selectItem = (item: RadioItem) => { + if(item.disabled){ return; } + onItemSelected?.(item); + } + return (
{items.map(i => ( -
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}`}> +
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}`}>
@@ -47,4 +52,5 @@ export interface RadioItem { textIcon?: string; className?: string; value?: T; + disabled?: boolean; } diff --git a/src/renderer/pages/settings-page.component.tsx b/src/renderer/pages/settings-page.component.tsx index bccd2bf6..f813fd9a 100644 --- a/src/renderer/pages/settings-page.component.tsx +++ b/src/renderer/pages/settings-page.component.tsx @@ -235,7 +235,7 @@ export function SettingsPage() { }, - { id: 2, text: "Oculus Store (PC)", value: BsStore.OCULUS, icon: }, + { id: 2, text: "Oculus Store (PC)", value: BsStore.OCULUS, icon: , disabled: true}, { id: 0, text: t("pages.settings.steam-and-oculus.download-platform.always-ask"), value: undefined, }, ]} selectedItemValue={downloadStore} onItemSelected={handleChangeBsStore}/> diff --git a/src/renderer/services/bs-version-download/bs-downloader.service.ts b/src/renderer/services/bs-version-download/bs-downloader.service.ts index 200a5df8..f36d1876 100644 --- a/src/renderer/services/bs-version-download/bs-downloader.service.ts +++ b/src/renderer/services/bs-version-download/bs-downloader.service.ts @@ -75,7 +75,7 @@ export class BsDownloaderService extends AbstractBsDownloaderService { public async downloadVersion(version: BSVersion, from?: BsStore): Promise { 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(() => {