Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UX] Prefer using release dates from each runner #3446

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/backend/storeManagers/gog/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,17 @@ export async function getExtraInfo(appName: string): Promise<ExtraInfo> {
}

const reqs = await createReqsArray(appName, targetPlatform)
const storeUrl = (await getGamesData(appName))?._links.store.href
const data = await getGamesData(appName)
const storeUrl = data?._links.store.href
const releaseDate = data?._embedded.product?.globalReleaseDate?.substring(
0,
19
Comment on lines +106 to +108
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

substring here ensures we ommit the timezone, it creates confusing things.

e.g 1980-01-01T00:00:00+02:00 - if we didn't ignore the timezone the date might turn out to be invalid in this context: 1979-12-31

)

const extra: ExtraInfo = {
about: gameInfo.extra?.about,
reqs,
releaseDate,
storeUrl
}
return extra
Expand Down
1 change: 1 addition & 0 deletions src/backend/storeManagers/legendary/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ async function getExtraFromAPI(slug: string): Promise<ExtraInfo | null> {
return {
about: about.data.about,
reqs: about.data.requirements.systems[0].details,
releaseDate: about.data.meta.releaseDate?.substring(0, 19),
storeUrl: `https://www.epicgames.com/store/product/${slug}`
}
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/backend/wiki_game_info/wiki_game_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export async function getWikiGameInfo(

let steamInfo = null
if (isLinux) {
const steamID = pcgamingwiki?.steamID || gamesdb?.steamID
// gamesdb is more accurate since we always query by appName
// pcgamingwiki is queried by title in most cases
const steamID = gamesdb?.steamID || pcgamingwiki?.steamID
const [protondb, steamdeck] = await Promise.all([
getInfoFromProtonDB(steamID),
getSteamDeckComp(steamID)
Expand Down
1 change: 1 addition & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export type ExecResult = {
export interface ExtraInfo {
about?: About
reqs: Reqs[]
releaseDate?: string
storeUrl?: string
}

Expand Down
37 changes: 20 additions & 17 deletions src/frontend/screens/Game/GamePage/components/ReleaseDate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import GameContext from '../../GameContext'

type ReleaseDateProps = {
date: string[] | undefined
runnerDate: string | undefined
}

// convert date to current locale using Intl module
Expand All @@ -16,7 +17,7 @@ function convertDate(date: string) {

const options: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'long',
month: 'numeric',
day: 'numeric'
}

Expand All @@ -30,7 +31,7 @@ function convertDate(date: string) {
return dateObj.toLocaleDateString(undefined, options)
}

const ReleaseDate: React.FC<ReleaseDateProps> = ({ date }) => {
const ReleaseDate: React.FC<ReleaseDateProps> = ({ date, runnerDate }) => {
const { is } = useContext(GameContext)

const { t } = useTranslation()
Expand All @@ -40,24 +41,26 @@ const ReleaseDate: React.FC<ReleaseDateProps> = ({ date }) => {
}

const getReleaseDate = () => {
let windowsReleaseDate = ''

for (let i = 0; i < date.length; i++) {
const [platformName, releaseDate] = date[i].split(': ')

if (platformName === 'Windows') {
windowsReleaseDate = releaseDate
}

if (
(platformName === 'Linux' && is.linuxNative && is.linux) ||
(platformName === 'OS X' && is.macNative && is.mac)
) {
return convertDate(releaseDate)
let windowsReleaseDate = runnerDate

if (!windowsReleaseDate) {
for (let i = 0; i < date.length; i++) {
const [platformName, releaseDate] = date[i].split(': ')

if (platformName === 'Windows') {
windowsReleaseDate = releaseDate
}

if (
(platformName === 'Linux' && is.linuxNative && is.linux) ||
(platformName === 'OS X' && is.macNative && is.mac)
) {
return convertDate(releaseDate)
}
}
}

return convertDate(windowsReleaseDate)
return convertDate(windowsReleaseDate || '')
}

if (!getReleaseDate()) {
Expand Down
10 changes: 8 additions & 2 deletions src/frontend/screens/Game/GamePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ export default React.memo(function GamePage(): JSX.Element | null {
<div className="infoWrapper">
<Genres genres={wikiInfo?.pcgamingwiki?.genres || []} />
<Developer gameInfo={gameInfo} />
<ReleaseDate date={wikiInfo?.pcgamingwiki?.releaseDate} />
<ReleaseDate
runnerDate={extraInfo?.releaseDate}
date={wikiInfo?.pcgamingwiki?.releaseDate}
/>
<Description />
<CloudSavesSync gameInfo={gameInfo} />
<DownloadSizeInfo gameInfo={gameInfo} />
Expand Down Expand Up @@ -435,7 +438,10 @@ export default React.memo(function GamePage(): JSX.Element | null {
<h1>{title}</h1>
<Genres genres={wikiInfo?.pcgamingwiki?.genres || []} />
<Developer gameInfo={gameInfo} />
<ReleaseDate date={wikiInfo?.pcgamingwiki?.releaseDate} />
<ReleaseDate
runnerDate={extraInfo?.releaseDate}
date={wikiInfo?.pcgamingwiki?.releaseDate}
/>
<Description />
{!notInstallable && (
<TimeContainer runner={runner} game={appName} />
Expand Down