From 08517c14f8173108d239fe93f406244df2357c86 Mon Sep 17 00:00:00 2001 From: Viet Nguyen <3805254+vnugent@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:23:14 -0800 Subject: [PATCH] fix: quick links to countries are slow (#1234) * fix: increase area page cache time * fix: disable prefetching to reduce load * fix: upgrade react-dropzone to fix mysterious undefined.every() error --- package.json | 2 +- src/app/(default)/area/[[...slug]]/page.tsx | 3 +- .../(default)/components/DesktopHeader.tsx | 1 + .../(default)/components/InternationalToC.tsx | 2 +- src/app/(default)/components/USAToC.tsx | 4 +-- src/components/media/Tag.tsx | 4 +-- yarn.lock | 35 +++++++++++-------- 7 files changed, 28 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 38bd5c56e..cc29e4612 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "react": "^18.2.0", "react-content-loader": "^6.2.0", "react-dom": "^18.2.0", - "react-dropzone": "^14.2.1", + "react-dropzone": "^14.3.5", "react-hook-form": "^7.34.2", "react-hotkeys-hook": "^3.4.7", "react-infinite-scroll-component": "^6.1.0", diff --git a/src/app/(default)/area/[[...slug]]/page.tsx b/src/app/(default)/area/[[...slug]]/page.tsx index 3a45406cc..3c6875a50 100644 --- a/src/app/(default)/area/[[...slug]]/page.tsx +++ b/src/app/(default)/area/[[...slug]]/page.tsx @@ -22,8 +22,7 @@ import { PageWithCatchAllUuidProps, PageSlugType } from '@/js/types/pages' /** * Page cache settings */ -export const revalidate = 300 // 5 mins -export const fetchCache = 'force-no-store' // opt out of Nextjs version of 'fetch' +export const revalidate = 3600 // 1 hr /** * Area/crag page diff --git a/src/app/(default)/components/DesktopHeader.tsx b/src/app/(default)/components/DesktopHeader.tsx index 7311ae42b..e7b00b140 100644 --- a/src/app/(default)/components/DesktopHeader.tsx +++ b/src/app/(default)/components/DesktopHeader.tsx @@ -115,6 +115,7 @@ const QuickLinks: React.FC = () => { {icon}{label} diff --git a/src/app/(default)/components/InternationalToC.tsx b/src/app/(default)/components/InternationalToC.tsx index 809702932..14446d358 100644 --- a/src/app/(default)/components/InternationalToC.tsx +++ b/src/app/(default)/components/InternationalToC.tsx @@ -25,7 +25,7 @@ const CountryCard: React.FC<{ country: ToCCountry }> = ({ country }) => { const { areaName, uuid, children } = country return (
- + {areaName}
diff --git a/src/app/(default)/components/USAToC.tsx b/src/app/(default)/components/USAToC.tsx index 71241a38d..3d494da6e 100644 --- a/src/app/(default)/components/USAToC.tsx +++ b/src/app/(default)/components/USAToC.tsx @@ -11,7 +11,7 @@ export const USAToC: React.FC = async () => { return ( +

USA

} @@ -21,7 +21,7 @@ export const USAToC: React.FC = async () => { const { name, uuid, totalClimbs, areas } = state return (
- + {name} {new Intl.NumberFormat().format(totalClimbs)} diff --git a/src/components/media/Tag.tsx b/src/components/media/Tag.tsx index 1892e631f..a2c2d1857 100644 --- a/src/components/media/Tag.tsx +++ b/src/components/media/Tag.tsx @@ -6,7 +6,7 @@ import clx from 'classnames' import { EntityTag, TagTargetType } from '../../js/types' import { OnDeleteCallback } from './TagList' import { MouseEventHandler } from 'react' -import { getAreaPageFriendlyUrl } from '@/js/utils' +import { getAreaPageFriendlyUrl, getClimbPageFriendlyUrl } from '@/js/utils' interface PhotoTagProps { mediaId: string @@ -68,7 +68,7 @@ export const resolver = (props: EntityTag): [string, string] | [null, null] => { const { targetId: id, climbName, areaName, type } = props switch (type) { case TagTargetType.climb: { - return [`/climb/${id}`, climbName ?? ''] + return [getClimbPageFriendlyUrl(id, climbName ?? ''), climbName ?? ''] } case TagTargetType.area: { return [getAreaPageFriendlyUrl(id, areaName), areaName] diff --git a/yarn.lock b/yarn.lock index a8cd5783a..757aeae67 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3217,10 +3217,10 @@ asynckit@^0.4.0: resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== -attr-accept@^2.2.2: - version "2.2.2" - resolved "https://registry.npmjs.org/attr-accept/-/attr-accept-2.2.2.tgz" - integrity sha512-7prDjvt9HmqiZ0cl5CRjtS84sEyhsHP2coDkaZKRKVfCDo9s7iw7ChVmar78Gu9pC4SoR/28wFu/G5JJhTnqEg== +attr-accept@^2.2.4: + version "2.2.5" + resolved "https://registry.yarnpkg.com/attr-accept/-/attr-accept-2.2.5.tgz#d7061d958e6d4f97bf8665c68b75851a0713ab5e" + integrity sha512-0bDNnY/u6pPwHDMoF0FieU354oBi0a8rD9FcsLwzcGWbc8KS8KPIi7y+s13OlVY+gMWc/9xEMUgNE6Qm8ZllYQ== auth0@^4.12.0: version "4.12.0" @@ -4754,12 +4754,12 @@ file-saver@^2.0.5: resolved "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz" integrity sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA== -file-selector@^0.6.0: - version "0.6.0" - resolved "https://registry.npmjs.org/file-selector/-/file-selector-0.6.0.tgz" - integrity sha512-QlZ5yJC0VxHxQQsQhXvBaC7VRJ2uaxTf+Tfpu4Z/OcVQJVpZO+DGU0rkoVW5ce2SccxugvpBJoMvUs59iILYdw== +file-selector@^2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/file-selector/-/file-selector-2.1.2.tgz#fe7c7ee9e550952dfbc863d73b14dc740d7de8b4" + integrity sha512-QgXo+mXTe8ljeqUFaX3QVHc5osSItJ/Km+xpocx0aSqWGMSCf6qYs/VnzZgS864Pjn5iceMRFigeAV7AfTlaig== dependencies: - tslib "^2.4.0" + tslib "^2.7.0" fill-range@^7.0.1: version "7.0.1" @@ -7468,13 +7468,13 @@ react-dom@^18.2.0: loose-envify "^1.1.0" scheduler "^0.23.0" -react-dropzone@^14.2.1: - version "14.2.3" - resolved "https://registry.npmjs.org/react-dropzone/-/react-dropzone-14.2.3.tgz" - integrity sha512-O3om8I+PkFKbxCukfIR3QAGftYXDZfOE2N1mr/7qebQJHs7U+/RSL/9xomJNpRg9kM5h9soQSdf0Gc7OHF5Fug== +react-dropzone@^14.3.5: + version "14.3.5" + resolved "https://registry.yarnpkg.com/react-dropzone/-/react-dropzone-14.3.5.tgz#1a8bd312c8a353ec78ef402842ccb3589c225add" + integrity sha512-9nDUaEEpqZLOz5v5SUcFA0CjM4vq8YbqO0WRls+EYT7+DvxUdzDPKNCPLqGfj3YL9MsniCLCD4RFA6M95V6KMQ== dependencies: - attr-accept "^2.2.2" - file-selector "^0.6.0" + attr-accept "^2.2.4" + file-selector "^2.1.0" prop-types "^15.8.1" react-error-boundary@^3.1.4: @@ -8678,6 +8678,11 @@ tslib@^2.0.0, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.4.0: resolved "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== +tslib@^2.7.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz"