Skip to content

Commit

Permalink
[bug] Don't show access code on mod dialog if no access code required (
Browse files Browse the repository at this point in the history
…#1206)

* Don't show access code on mod dialog if no access code required

* Update accessCode check in mod dialog & cleanup channel logic

* Add missing null check

* Still show other advanced options but not option 4 if isGated
  • Loading branch information
jiyuu-jin authored Jan 14, 2025
1 parent a6e26ea commit 68f7216
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface Props {
winePrefix: string
crossoverBottle: string
wineVersion: WineInstallation | undefined
isGated: boolean
}

const userHome = configStore.get('userHome', '')
Expand All @@ -43,7 +44,8 @@ const ModDialog: React.FC<Props> = ({
enableCTAButton,
winePrefix,
wineVersion,
crossoverBottle
crossoverBottle,
isGated
}) => {
const { t } = useTranslation()
const flags = useFlags()
Expand Down Expand Up @@ -246,19 +248,23 @@ const ModDialog: React.FC<Props> = ({
className={styles.step}
style={{ paddingBottom: 'var(--space-xl-fixed)' }}
>
<div className={styles.stepTitle}>
{t('mods.instructions.step4.title', 'Step 4')}
</div>
<div className={styles.stepSubtitle}>
{t('mods.instructions.step4.subtitle', 'Access Code')}
</div>
<span className={styles.stepDescription}>
{t('mods.instructions.step4.description', {
defaultValue:
'Enter the access code to proceed with installing the game.',
newline: '\n'
})}
</span>
{isGated && (
<>
<div className={styles.stepTitle}>
{t('mods.instructions.step4.title', 'Step 4')}
</div>
<div className={styles.stepSubtitle}>
{t('mods.instructions.step4.subtitle', 'Access Code')}
</div>
<span className={styles.stepDescription}>
{t('mods.instructions.step4.description', {
defaultValue:
'Enter the access code to proceed with installing the game.',
newline: '\n'
})}
</span>
</>
)}
{children}
</div>
)}
Expand Down
10 changes: 4 additions & 6 deletions src/frontend/screens/Library/components/InstallModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ export default React.memo(function InstallModal({
const [crossoverBottle, setCrossoverBottle] = useState('')
const [accessCode, setAccessCode] = useState('')

const numberOfChannels =
(gameInfo?.channels && Object.keys(gameInfo?.channels).length) ?? 0
const initChannelName =
gameInfo?.channels && numberOfChannels > 0
? Object.keys(gameInfo?.channels)[0]
: 'main'
const channelKeys = Object.keys(gameInfo?.channels || {})
const numberOfChannels = channelKeys.length
const initChannelName = numberOfChannels > 0 ? channelKeys[0] : 'main'
const [channelNameToInstall, setChannelNameToInstall] =
useState(initChannelName)

Expand Down Expand Up @@ -312,6 +309,7 @@ export default React.memo(function InstallModal({
winePrefix={winePrefix}
wineVersion={wineVersion}
crossoverBottle={crossoverBottle}
isGated={selectedChannel?.license_config?.access_codes ?? false}
>
<div style={{ paddingTop: 'var(--space-md)' }}>
{runner === 'hyperplay' && numberOfChannels > 1 ? (
Expand Down

0 comments on commit 68f7216

Please sign in to comment.