From 74777ef87fdb0039dbce0422e8eb7948db7640c1 Mon Sep 17 00:00:00 2001 From: Jonathan Sykes Date: Wed, 30 Sep 2026 00:18:22 +0800 Subject: [PATCH] show a lightning icon on recent searches that will load instantly --- frontend/app.js | 15 +++++++++++---- frontend/styles.css | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/app.js b/frontend/app.js index 6d63a84..123f95d 100755 --- a/frontend/app.js +++ b/frontend/app.js @@ -145,6 +145,9 @@ const RecentSearches = (() => { const hit = loadResults()[norm(q)]; return hit && Array.isArray(hit.results) && hit.results.length ? hit : null; }, + // Normalized queries that have a cached result set — one localStorage + // read for the whole dropdown, rather than one per row. + cachedQueries() { return new Set(Object.keys(loadResults())); }, }; })(); @@ -8622,11 +8625,15 @@ function wireUI() { function renderRecentSearches() { const list = RecentSearches.list(); if (!list.length) { els.searchRecent.innerHTML = ''; return; } - els.searchRecent.innerHTML = list.map((q) => ` -
- 🕐${escapeHtml(q)} + const cachedQueries = RecentSearches.cachedQueries(); + els.searchRecent.innerHTML = list.map((q) => { + const isCached = cachedQueries.has(q.trim().toLowerCase()); + return ` +
+ ${isCached ? '⚡' : '🕐'}${escapeHtml(q)} -
`).join('') + ''; +
`; + }).join('') + ''; } function showRecentSearches() { renderRecentSearches(); diff --git a/frontend/styles.css b/frontend/styles.css index 863574c..1da1529 100755 --- a/frontend/styles.css +++ b/frontend/styles.css @@ -304,6 +304,7 @@ body::after { } .search-recent-row:hover, .search-recent-row:focus-visible { background: var(--bg-3); color: var(--text); } .search-recent-row .sr-icon { flex-shrink: 0; opacity: 0.55; font-size: 12px; } +.search-recent-row.is-cached .sr-icon { opacity: 0.85; color: var(--accent); } .search-recent-row .sr-text { flex: 1; overflow: hidden;