refactor(extension): consolidate 5 relativeTime copies into shared util
This commit is contained in:
@@ -3,19 +3,9 @@
|
||||
import { getState, setState, sendMessage, navigate, escapeHtml } from '../../shared/state';
|
||||
import { colorizePassword } from '../../shared/password-coloring';
|
||||
import type { FieldHistoryView } from '../../shared/types';
|
||||
import { relativeTime } from '../../shared/relative-time';
|
||||
import { GLYPH_COPY } from '../../shared/glyphs';
|
||||
|
||||
function relativeTime(unixSec: number): string {
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const diff = now - unixSec;
|
||||
if (diff < 60) return 'just now';
|
||||
if (diff < 3600) return `${Math.floor(diff / 60)}m ago`;
|
||||
if (diff < 86400) return `${Math.floor(diff / 3600)}h ago`;
|
||||
if (diff < 604800) return `${Math.floor(diff / 86400)}d ago`;
|
||||
if (diff < 2592000) return `${Math.floor(diff / 604800)}w ago`;
|
||||
return `${Math.floor(diff / 2592000)}mo ago`;
|
||||
}
|
||||
|
||||
const revealedSet = new Set<string>();
|
||||
|
||||
// Map from entry key → plaintext value; populated on each render so we never
|
||||
|
||||
Reference in New Issue
Block a user