-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/ipdt_patching
- Loading branch information
Showing
25 changed files
with
472 additions
and
465 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...rlayManager/Overlay/NavBarOverlayWrapper/MarketplaceNavItem/MarketplaceSublinks/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react' | ||
import { ContractMetadata } from '@valist/sdk/dist/typesApi' | ||
import { SubLink } from '@hyperplay/ui' | ||
import { Link, useLocation } from 'react-router-dom' | ||
import styles from '../../index.module.scss' | ||
|
||
export function MarketplaceSublinks(contractMetadata?: ContractMetadata[]) { | ||
const location = useLocation() | ||
const { pathname, search } = location | ||
const searchParams = new URLSearchParams(search) | ||
const urlQueryParam = searchParams.get('url') | ||
|
||
const marketplaceSublinks = contractMetadata | ||
?.filter((val) => !!val.marketplace_urls) | ||
.flatMap((val) => | ||
(val.marketplace_urls ?? []) | ||
.filter((val) => !!val) | ||
.map((mktUrl) => { | ||
return ( | ||
<SubLink | ||
key={val.name} | ||
component={Link} | ||
to={`/marketplace?url=${encodeURIComponent(mktUrl)}`} | ||
selected={pathname === '/marketplace' && urlQueryParam === mktUrl} | ||
className={styles.sublink} | ||
> | ||
{val.name} | ||
</SubLink> | ||
) | ||
}) | ||
) | ||
return marketplaceSublinks | ||
} |
62 changes: 62 additions & 0 deletions
62
src/frontend/OverlayManager/Overlay/NavBarOverlayWrapper/MarketplaceNavItem/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { useState } from 'react' | ||
import { Images, NavItem } from '@hyperplay/ui' | ||
import { useLocation } from 'react-router-dom' | ||
import { useQuery } from '@tanstack/react-query' | ||
import { BrowserGameProps } from 'frontend/OverlayManager/types' | ||
import styles from '../index.module.scss' | ||
import classNames from 'classnames' | ||
import { useTranslation } from 'react-i18next' | ||
import { MarketplaceSublinks } from './MarketplaceSublinks' | ||
|
||
export interface MarketplaceNavItemProps extends BrowserGameProps { | ||
collapsed: boolean | ||
} | ||
|
||
export function MarketplaceNavItem({ | ||
appName, | ||
runner, | ||
collapsed, | ||
...props | ||
}: MarketplaceNavItemProps) { | ||
const location = useLocation() | ||
const { pathname } = location | ||
const [mktCollapsed, setMktCollapsed] = useState(false) | ||
const { t } = useTranslation() | ||
|
||
const { data: gameInfo } = useQuery({ | ||
queryKey: ['getGameInfo', appName], | ||
queryFn: async () => { | ||
return window.api.getGameInfo(appName, runner) | ||
} | ||
}) | ||
|
||
const gameInfoExists = !!gameInfo | ||
const gameInfoHasSomeMarketplaceUrls = !!gameInfo?.networks?.some( | ||
(val) => !!val.marketplace_urls?.length | ||
) | ||
const marketplaceEnabled = gameInfoExists && gameInfoHasSomeMarketplaceUrls | ||
const marketplaceClass: Record<string, boolean> = {} | ||
marketplaceClass[styles.disabled] = !marketplaceEnabled | ||
|
||
if (!marketplaceEnabled) { | ||
return null | ||
} | ||
|
||
return ( | ||
<NavItem | ||
title={t('overlay.links.marketplace', 'Marketplace')} | ||
icon={<Images.Home fill="white" />} | ||
key={'/marketplace'} | ||
collapsed={collapsed} | ||
selected={pathname === '/marketplace'} | ||
classNames={{ link: classNames(marketplaceClass) }} | ||
subLinks={ | ||
marketplaceEnabled ? MarketplaceSublinks(gameInfo?.networks) : undefined | ||
} | ||
subLinksCollapsed={mktCollapsed} | ||
setSubLinksCollapsed={() => setMktCollapsed(!mktCollapsed)} | ||
onClick={() => setMktCollapsed(!mktCollapsed)} | ||
{...props} | ||
/> | ||
) | ||
} |
Oops, something went wrong.