Skip to content

Commit 2134014

Browse files
committed
fix: rm force unwrap, conditionally render component
getLocaleTimestamp requires a date string but was occasionally getting an empty string or undefined; this confirms a value exists for the argument before rendering the component that makes this function call
1 parent 1736d4c commit 2134014

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/components/Footer.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,12 @@ const Footer = ({ lastDeployDate }: FooterProps) => {
298298
alignItems="center"
299299
flexWrap="wrap"
300300
>
301-
<Box color="text200">
302-
<Translation id="website-last-updated" />:{" "}
303-
{getLocaleTimestamp(locale as Lang, lastDeployDate!)}
304-
</Box>
301+
{lastDeployDate && (
302+
<Box color="text200">
303+
<Translation id="website-last-updated" />:{" "}
304+
{getLocaleTimestamp(locale as Lang, lastDeployDate)}
305+
</Box>
306+
)}
305307
<Box my={4}>
306308
{socialLinks.map((link, idk) => {
307309
return (

src/layouts/Static.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ export const StaticLayout = ({
119119
) : (
120120
<>
121121
<Breadcrumbs slug={slug} mb="8" />
122-
<Text
123-
color="text200"
124-
dir={isLangRightToLeft(locale as Lang) ? "rtl" : "ltr"}
125-
>
126-
<Translation id="page-last-updated" />:{" "}
127-
{getLocaleTimestamp(locale as Lang, lastUpdatedDate!)}
128-
</Text>
122+
{lastUpdatedDate && (
123+
<Text
124+
color="text200"
125+
dir={isLangRightToLeft(locale as Lang) ? "rtl" : "ltr"}
126+
>
127+
<Translation id="page-last-updated" />:{" "}
128+
{getLocaleTimestamp(locale as Lang, lastUpdatedDate)}
129+
</Text>
130+
)}
129131
</>
130132
)}
131133

src/layouts/Upgrade.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Icon,
1010
List,
1111
ListItem,
12+
Skeleton,
1213
Text,
1314
useToken,
1415
} from "@chakra-ui/react"
@@ -193,10 +194,12 @@ export const UpgradeLayout = ({
193194
))}
194195
</List>
195196
</Box>
196-
<LastUpdated>
197-
{t("common:page-last-updated")}:{" "}
198-
{getLocaleTimestamp(locale as Lang, lastUpdatedDate!)}
199-
</LastUpdated>
197+
{lastUpdatedDate && (
198+
<LastUpdated>
199+
{t("common:page-last-updated")}:{" "}
200+
{getLocaleTimestamp(locale as Lang, lastUpdatedDate)}
201+
</LastUpdated>
202+
)}
200203
</TitleCard>
201204
{frontmatter.image && (
202205
<Image

src/pages/developers/tutorials.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ const TutorialPage = ({
473473
</Flex>
474474
<Text color="text200" fontSize="sm" textTransform="uppercase">
475475
<Emoji text=":writing_hand:" fontSize="sm" me={2} />
476-
{tutorial.author}
477-
{published(locale!, tutorial.published ?? "")}
476+
{tutorial.author}
477+
{tutorial.published && " • " + published(locale!, tutorial.published)}
478478
{tutorial.timeToRead && (
479479
<>
480480
{" "}

0 commit comments

Comments
 (0)