Skip to content

Commit 403707e

Browse files
committed
fixup! async caching
1 parent 0986d38 commit 403707e

File tree

14 files changed

+27
-51
lines changed

14 files changed

+27
-51
lines changed

apps/site/app/[locale]/download/archive/[version]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const generateStaticParams = async () => {
3030
return [];
3131
}
3232

33-
const versions = provideReleaseVersions();
33+
const versions = await provideReleaseVersions();
3434

3535
return versions.map(version => ({
3636
locale: defaultLocale.code,
@@ -49,14 +49,14 @@ const getPage: FC<PageParams> = async props => {
4949
const [locale, pathname] = basePage.getLocaleAndPath(version, routeLocale);
5050

5151
if (version === 'current') {
52-
const releaseData = provideReleaseData();
52+
const releaseData = await provideReleaseData();
5353

5454
const release = releaseData.find(release => release.status === 'Current');
5555

5656
redirect(`/${locale}/download/archive/${release?.versionWithPrefix}`);
5757
}
5858

59-
const versions = provideReleaseVersions();
59+
const versions = await provideReleaseVersions();
6060

6161
// Verifies if the current route is a dynamic route
6262
const isDynamicRoute = versions.some(r => r.includes(pathname));

apps/site/components/EOL/EOLReleaseTable/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import EOLReleaseTableBody from './TableBody';
1212
import styles from './index.module.css';
1313

1414
const EOLReleaseTable: FC = async () => {
15-
const releaseData = provideReleaseData();
16-
const vulnerabilities = provideVulnerabilities();
15+
const releaseData = await provideReleaseData();
16+
const vulnerabilities = await provideVulnerabilities();
1717

1818
const eolReleases = releaseData.filter(
1919
release => release.status === EOL_VERSION_IDENTIFIER

apps/site/components/Releases/PreviousReleasesTable/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { FC } from 'react';
77
import PreviousReleasesTableBody from './TableBody';
88

99
const PreviousReleasesTable: FC = async () => {
10-
const releaseData = provideReleaseData();
10+
const releaseData = await provideReleaseData();
1111

1212
const t = await getTranslations();
1313

apps/site/components/withDownloadArchive.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type WithDownloadArchiveProps = {
1919
* Higher-order component that extracts version from pathname,
2020
* fetches release data, and provides download artifacts to child component
2121
*/
22-
const WithDownloadArchive: FC<WithDownloadArchiveProps> = ({
22+
const WithDownloadArchive: FC<WithDownloadArchiveProps> = async ({
2323
children: Component,
2424
}) => {
2525
const { pathname } = getClientContext();
@@ -28,7 +28,7 @@ const WithDownloadArchive: FC<WithDownloadArchiveProps> = ({
2828
const version = extractVersionFromPath(pathname);
2929

3030
// Find the release data for the given version
31-
const releaseData = provideReleaseData();
31+
const releaseData = await provideReleaseData();
3232
const release = releaseData.find(release =>
3333
// Match major version only (e.g., v22.x.x for release.major v22)
3434
version.startsWith(`v${release.major}`)

apps/site/components/withDownloadSection.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@ const WithDownloadSection: FC<WithDownloadSectionProps> = async ({
2222
}) => {
2323
const locale = await getLocale();
2424

25-
const snippets = provideDownloadSnippets(locale);
25+
const snippets = await provideDownloadSnippets();
26+
27+
const localeSnippets = snippets.get(locale) ?? [];
2628

2729
// By default the translated languages do not contain all the download snippets
2830
// Hence we always merge any translated snippet with the fallbacks for missing snippets
29-
const fallbackSnippets = provideDownloadSnippets(defaultLocale.code);
31+
const fallbackSnippets = snippets.get(defaultLocale.code) ?? [];
3032

3133
const { pathname } = getClientContext();
3234

3335
// Some available translations do not have download snippets translated or have them partially translated
3436
// This aims to merge the available translated snippets with the fallback snippets
3537
const memoizedSnippets = fallbackSnippets
36-
.filter(snippet => !snippets.some(s => s.name === snippet.name))
37-
.concat(snippets);
38+
.filter(snippet => !localeSnippets.some(s => s.name === snippet.name))
39+
.concat(localeSnippets);
3840

3941
// Decides which initial release to use based on the current pathname
4042
const initialRelease = pathname.endsWith('/current')

apps/site/components/withNodeRelease.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ type WithNodeReleaseProps = {
1010

1111
// This is a React Server Component
1212
// Note that Hooks cannot be used in a React Server Component
13-
const WithNodeRelease: FC<WithNodeReleaseProps> = ({
13+
const WithNodeRelease: FC<WithNodeReleaseProps> = async ({
1414
status: statuses,
1515
children: Component,
1616
}) => {
17-
const releases = provideReleaseData();
17+
const releases = await provideReleaseData();
1818

1919
const matchingRelease = [statuses]
2020
.flat()

apps/site/components/withReleaseSelect.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ type WithReleaseSelectProps = Omit<
4141
'values' | 'as'
4242
>;
4343

44-
const WithReleaseSelect: FC<WithReleaseSelectProps> = ({ ...props }) => {
45-
const releaseData = provideReleaseData();
44+
const WithReleaseSelect: FC<WithReleaseSelectProps> = async ({ ...props }) => {
45+
const releaseData = await provideReleaseData();
4646
const navigation = groupReleasesByStatus(releaseData);
4747

4848
return (

apps/site/components/withSupporters.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type { FC, PropsWithChildren } from 'react';
44

55
import SupportersList from './Common/Supporters';
66

7-
const WithSupporters: FC<PropsWithChildren> = () => {
8-
const supporters = provideSupporters();
7+
const WithSupporters: FC<PropsWithChildren> = async () => {
8+
const supporters = await provideSupporters();
99

1010
return (
1111
<div className="flex max-w-full flex-wrap items-center gap-1">

apps/site/layouts/Download.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import type { FC, PropsWithChildren } from 'react';
88

99
import styles from './layouts.module.css';
1010

11-
const DownloadLayout: FC<PropsWithChildren> = ({ children }) => {
11+
const DownloadLayout: FC<PropsWithChildren> = async ({ children }) => {
1212
const { frontmatter } = getClientContext();
1313

14-
const releases = provideReleaseData();
14+
const releases = await provideReleaseData();
1515

1616
return (
1717
<>

apps/site/next-data/providers/downloadSnippets.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,4 @@ import { cache } from 'react';
22

33
import generateDownloadSnippets from '#site/next-data/generators/downloadSnippets.mjs';
44

5-
const downloadSnippets = await generateDownloadSnippets();
6-
7-
const provideDownloadSnippets = cache((language: string) => {
8-
if (downloadSnippets.has(language)) {
9-
return downloadSnippets.get(language)!;
10-
}
11-
12-
return [];
13-
});
14-
15-
export default provideDownloadSnippets;
5+
export default cache(generateDownloadSnippets);

0 commit comments

Comments
 (0)