Skip to content

feat: adopt RelativeTime primer component #1750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions src/renderer/components/notifications/NotificationFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import type { FC, MouseEvent } from 'react';

import { FeedPersonIcon, MarkGithubIcon } from '@primer/octicons-react';
import { Avatar } from '@primer/react';
import { Avatar, RelativeTime, Stack, Text } from '@primer/react';

import { IconColor, Opacity, Size } from '../../types';
import type { Notification } from '../../typesGitHub';
import { cn } from '../../utils/cn';
import {
formatNotificationUpdatedAt,
isNonHumanUser,
} from '../../utils/helpers';
import { isNonHumanUser } from '../../utils/helpers';
import { openUserProfile } from '../../utils/links';
import { formatReason } from '../../utils/reason';
import { Pills } from './Pills';
Expand All @@ -23,13 +20,8 @@ export const NotificationFooter: FC<INotificationFooter> = ({
}: INotificationFooter) => {
const reason = formatReason(notification.reason);

const updatedAt = formatNotificationUpdatedAt(notification);
const updatedLabel = notification.subject.user
? `${notification.subject.user.login} updated ${updatedAt}`
: `Updated ${updatedAt}`;

return (
<div className="flex flex-wrap items-center gap-1">
<Stack direction="horizontal" align="center" gap="condensed" wrap="wrap">
{notification.subject.user ? (
<Avatar
title={`View profile: ${notification.subject.user.login}`}
Expand All @@ -53,19 +45,15 @@ export const NotificationFooter: FC<INotificationFooter> = ({
)}
</>
)}
<span
className={cn('text-xs capitalize', Opacity.MEDIUM)}
title={reason.description}
>
{reason.title}
</span>
<span
className={cn('text-xs capitalize', Opacity.MEDIUM)}
title={updatedLabel}
>
{updatedAt}
<span className={cn('text-xs', Opacity.MEDIUM)}>
<Stack direction="horizontal" gap="condensed">
<Text title={reason.description}>{reason.title}</Text>
<Text>&bull;</Text>
<RelativeTime datetime={notification.updated_at} />
</Stack>
</span>

<Pills notification={notification} />
</div>
</Stack>
);
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading