Skip to content

Commit

Permalink
Handle already chosen Oculus as default download platform
Browse files Browse the repository at this point in the history
  • Loading branch information
Zagrios committed Dec 17, 2023
1 parent 01bc0e1 commit 14036b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand All @@ -47,4 +52,5 @@ export interface RadioItem<T> {
textIcon?: string;
className?: string;
value?: T;
disabled?: boolean;
}
2 changes: 1 addition & 1 deletion src/renderer/pages/settings-page.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 14036b9

Please sign in to comment.