Favorites and Conversion History
15 min read
Sync Counters and Startup Rendering
Sync Counters and Startup Rendering
The sidebar contains Favorites and History counts. Centralize the updates so every write keeps the navigation accurate.
Add:
function counts() {
const favorites = $("favCount");
const history = $("historyCount");
if (favorites) favorites.textContent = read("fx-favorites").length;
if (history) history.textContent = read("fx-history").length;
}
Call counts() from your storage helper or after every render that changes stored data.
Finally, render the views once when the page loads:
renderFavorites();
renderHistory();
renderRates();
update();
Test it
Refresh the page after saving data.
Checkpoint
Favorites and History counts survive a refresh and match the stored items.