Skip to content

Commit

Permalink
feat: add "Just now" if event is 0 minutes ago
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Sep 11, 2024
1 parent 448da2e commit 853db20
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { ActivityLogAction } from "components/[guild]/activity/constants"
import ClientOnly from "components/common/ClientOnly"
import useSWRWithOptionalAuth from "hooks/useSWRWithOptionalAuth"
import useSWRImmutable from "swr/immutable"
import formatRelativeTimeFromNow from "utils/formatRelativeTimeFromNow"
import formatRelativeTimeFromNow, {
MINUTE_IN_MS,
} from "utils/formatRelativeTimeFromNow"
import { useProfile } from "../../_hooks/useProfile"
import { ProfileActionLabel } from "./ProfileActionLabel"

Expand Down Expand Up @@ -65,8 +67,13 @@ export const ActivityCard = ({ activity }: { activity: ActivityLogAction }) => {
<div className="mt-1 flex flex-wrap items-center gap-2">
<ClientOnly>
<p className="text-muted-foreground">
{formatRelativeTimeFromNow(Date.now() - parseInt(activity.timestamp))}{" "}
ago
{(() => {
const since = Date.now() - parseInt(activity.timestamp)
const sinceMinutes = since / MINUTE_IN_MS
return sinceMinutes === 0
? "Just now"
: `${formatRelativeTimeFromNow(since)} ago`
})()}
</p>
</ClientOnly>
</div>
Expand Down

0 comments on commit 853db20

Please sign in to comment.