♻️ Replace inline timeago with @lilith/ui-utils

- Add @lilith/ui-utils dependency for formatRelativeTime
- Remove local timeago.ts implementation
- Update ContactsPage and ConversationsPage imports

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lilith 2026-01-02 06:26:39 -08:00
parent 2aab35a1d0
commit 2da6058c86
4 changed files with 4 additions and 46 deletions

View file

@ -21,6 +21,7 @@
"@lilith/design-tokens": "workspace:*",
"@lilith/react-hooks": "workspace:*",
"@lilith/react-query-utils": "workspace:*",
"@lilith/ui-utils": "^1.0.1",
"@tanstack/react-query": "^5.17.0",
"lucide-react": "^0.553.0",
"react": "^18.2.0",

View file

@ -62,7 +62,7 @@ function formatSortValue(contact: Contact, sortBy: ContactSortBy): string {
case 'updatedAt':
default:
return contact.classificationUpdatedAt
? new Date(contact.classificationUpdatedAt).toLocaleDateString()
? formatRelativeTime(contact.classificationUpdatedAt)
: '-';
}
}

View file

@ -1,8 +1,8 @@
import { useRef, useEffect, useMemo, useCallback } from 'react';
import { Link } from 'react-router-dom';
import { User, Users, ChevronRight, Loader2 } from 'lucide-react';
import { formatRelativeTime } from '@lilith/ui-utils';
import { useConversationsInfinite } from '../api/hooks';
import { formatTimeAgo } from '../utils/timeago';
import styles from './ConversationsPage.module.css';
export function ConversationsPage() {
@ -90,7 +90,7 @@ export function ConversationsPage() {
<p className={styles.meta}>
{conversation.messageCount} messages
{conversation.lastMessageAt && (
<> · {formatTimeAgo(conversation.lastMessageAt)}</>
<> · {formatRelativeTime(conversation.lastMessageAt)}</>
)}
</p>
</div>

View file

@ -1,43 +0,0 @@
/**
* Format a date as a relative time string (e.g., "2 hours ago", "3 days ago")
*/
export function formatTimeAgo(date: Date | string | null | undefined): string {
if (!date) return '';
const now = new Date();
const then = typeof date === 'string' ? new Date(date) : date;
const diffMs = now.getTime() - then.getTime();
const diffSeconds = Math.floor(diffMs / 1000);
const diffMinutes = Math.floor(diffSeconds / 60);
const diffHours = Math.floor(diffMinutes / 60);
const diffDays = Math.floor(diffHours / 24);
const diffWeeks = Math.floor(diffDays / 7);
const diffMonths = Math.floor(diffDays / 30);
if (diffSeconds < 60) {
return 'just now';
}
if (diffMinutes < 60) {
return diffMinutes === 1 ? '1 minute ago' : `${diffMinutes} minutes ago`;
}
if (diffHours < 24) {
return diffHours === 1 ? '1 hour ago' : `${diffHours} hours ago`;
}
if (diffDays < 7) {
return diffDays === 1 ? '1 day ago' : `${diffDays} days ago`;
}
if (diffWeeks < 4) {
return diffWeeks === 1 ? '1 week ago' : `${diffWeeks} weeks ago`;
}
if (diffMonths < 12) {
return diffMonths === 1 ? '1 month ago' : `${diffMonths} months ago`;
}
// For older dates, show the actual date
return then.toLocaleDateString();
}