feat: remove recent conversions functionality from units
- Delete ConversionHistory component - Remove history-related logic and state from MainConverter - Clean up history imports and types in CommandPalette and storage utilities - Remove history storage functions from lib/units/storage.ts
This commit is contained in:
@@ -2,63 +2,7 @@
|
||||
* LocalStorage utilities for persisting user data
|
||||
*/
|
||||
|
||||
export interface ConversionRecord {
|
||||
id: string;
|
||||
timestamp: number;
|
||||
from: {
|
||||
value: number;
|
||||
unit: string;
|
||||
};
|
||||
to: {
|
||||
value: number;
|
||||
unit: string;
|
||||
};
|
||||
measure: string;
|
||||
}
|
||||
|
||||
const HISTORY_KEY = 'units-ui-history';
|
||||
const FAVORITES_KEY = 'units-ui-favorites';
|
||||
const MAX_HISTORY = 50;
|
||||
|
||||
/**
|
||||
* Save conversion to history
|
||||
*/
|
||||
export function saveToHistory(record: Omit<ConversionRecord, 'id' | 'timestamp'>): void {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
const history = getHistory();
|
||||
const newRecord: ConversionRecord = {
|
||||
...record,
|
||||
id: crypto.randomUUID(),
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
|
||||
// Add to beginning and limit size
|
||||
const updated = [newRecord, ...history].slice(0, MAX_HISTORY);
|
||||
localStorage.setItem(HISTORY_KEY, JSON.stringify(updated));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get conversion history
|
||||
*/
|
||||
export function getHistory(): ConversionRecord[] {
|
||||
if (typeof window === 'undefined') return [];
|
||||
|
||||
try {
|
||||
const stored = localStorage.getItem(HISTORY_KEY);
|
||||
return stored ? JSON.parse(stored) : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear conversion history
|
||||
*/
|
||||
export function clearHistory(): void {
|
||||
if (typeof window === 'undefined') return;
|
||||
localStorage.removeItem(HISTORY_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get favorite units
|
||||
|
||||
Reference in New Issue
Block a user