refactor(extension): consolidate 5 relativeTime copies into shared util
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user