refactor(extension): consolidate 5 relativeTime copies into shared util

This commit is contained in:
adlee-was-taken
2026-05-24 18:28:21 -04:00
parent 9da45dd478
commit a587965528
5 changed files with 5 additions and 55 deletions

View File

@@ -6,6 +6,7 @@ import { getState, setState, sendMessage, navigate, escapeHtml, openVaultTab } f
import type {
VaultSettings, TrashRetention, HistoryRetention, GeneratorRequest,
} from '../../shared/types';
import { relativeTime } from '../../shared/relative-time';
import { openGeneratorPanel, closeGeneratorPanel, isGeneratorPanelOpen } from './generator-panel';
import { GLYPH_NEXT } from '../../shared/glyphs';
@@ -65,17 +66,6 @@ function generatorSummary(req: GeneratorRequest): string {
return `BIP39, ${req.word_count} words, "${req.separator}" separator, ${req.capitalization}`;
}
// --- Time formatting ---
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`;
return `${Math.floor(diff / 86400)}d ago`;
}
// --- Render ---
export function renderVaultSettings(app: HTMLElement): void {