Skip to content

Commit 97216ae

Browse files
committed
chore: simplify time formatting logic in explore
1 parent dfb5e84 commit 97216ae

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

src/components/explore/ExploreBots.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Icon from "../ui/icon/Icon";
1515
import { Notice } from "../ui/Notice/Notice";
1616
import Text from "../ui/Text";
1717
import { Banner } from "../ui/Banner";
18-
import { getDaysAgo, timeSince } from "@/common/date";
18+
import { timeSince } from "@/common/date";
1919
import { toast, useCustomPortal } from "../ui/custom-portal/CustomPortal";
2020
import { Skeleton } from "../ui/skeleton/Skeleton";
2121
import { classNames, cn } from "@/common/classNames";
@@ -352,12 +352,6 @@ function PublicItem(props: {
352352
));
353353
};
354354

355-
const bumpedUnder24Hours = () => {
356-
const millisecondsSinceLastBump =
357-
new Date().getTime() - props.item.bumpedAt;
358-
return millisecondsSinceLastBump < 24 * 60 * 60 * 1000;
359-
};
360-
361355
return (
362356
<ServerItemContainer
363357
class={classNames(
@@ -434,9 +428,7 @@ function PublicItem(props: {
434428
<Icon name="schedule" size={17} color="var(--primary-color)" />
435429
<Text size={14}>
436430
{t("explore.bumped")}{" "}
437-
{(bumpedUnder24Hours() ? timeSince : getDaysAgo)(
438-
props.item.bumpedAt
439-
)}
431+
{timeSince(props.item.bumpedAt, false)}
440432
</Text>
441433
</FlexRow>
442434
</MemberContainer>

src/components/explore/ExploreServers.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Icon from "../ui/icon/Icon";
1717
import { Notice } from "../ui/Notice/Notice";
1818
import Text from "../ui/Text";
1919
import { Banner } from "../ui/Banner";
20-
import { getDaysAgo, timeSince } from "@/common/date";
20+
import { timeSince } from "@/common/date";
2121
import { toast, useCustomPortal } from "../ui/custom-portal/CustomPortal";
2222
import LegacyModal from "../ui/legacy-modal/LegacyModal";
2323
import { Turnstile, TurnstileRef } from "@nerimity/solid-turnstile";
@@ -411,12 +411,6 @@ function PublicServerItem(props: {
411411
));
412412
};
413413

414-
const bumpedUnder24Hours = () => {
415-
const millisecondsSinceLastBump =
416-
new Date().getTime() - props.publicServer.bumpedAt;
417-
return millisecondsSinceLastBump < 24 * 60 * 60 * 1000;
418-
};
419-
420414
return (
421415
<ServerItemContainer
422416
class={classNames(
@@ -497,9 +491,7 @@ function PublicServerItem(props: {
497491
<Icon name="schedule" size={17} color="var(--primary-color)" />
498492
<Text size={14}>
499493
{t("explore.bumped")}{" "}
500-
{(bumpedUnder24Hours() ? timeSince : getDaysAgo)(
501-
props.publicServer.bumpedAt,
502-
)}
494+
{timeSince(props.publicServer.bumpedAt, false)}
503495
</Text>
504496
</FlexRow>
505497
</MemberContainer>

0 commit comments

Comments
 (0)