History entries sorted by descending timestamp, or [] on failure.
const history = await getSearchHistory(); // => [{ query: "acetone", timestamp: 172… }]
export async function getSearchHistory(): Promise<SearchHistoryEntry[]> {
try {
const db = await getDB();
const all = await db.getAll(IDB_STORE.SEARCH_HISTORY);
// Return sorted newest-first
return all.sort((a, b) => b.timestamp - a.timestamp);
} catch (error) {
logger.error('Failed to get search history from IndexedDB', { error });
return [];
}
}
Reads every search-history entry, newest first.