Fix live current & best dates in popup

This commit is contained in:
Maks Snegov 2024-04-27 22:46:50 -07:00
parent 3f2ba8bd2a
commit 90a58961d4

View File

@ -150,20 +150,18 @@ function smoothTextChange(element, newText) {
}); });
// update current & best dates // update current & best dates
chrome.storage.onChanged.addListener((changes, area) => { chrome.storage.onChanged.addListener((changes, area) => {
if (area === 'local' && changes.ctx_consulates) { if (changes.ctx_consulates) {
const newConsulates = changes.ctx_consulates.newValue; const newConsulates = changes.ctx_consulates.newValue;
for (let c in newConsulates) { if (newConsulates[c].currentDate) {
if (newConsulates[c].currentDate) { let el = document.getElementById(`currentDate-${cId}`);
let el = document.getElementById(`currentDate-${c}`); if (el && el.innerText != newConsulates[c].currentDate)
if (el && el.innerText != newConsulates[c].currentDate) smoothTextChange(el, newConsulates[c].currentDate);
smoothTextChange(el, newConsulates[c].currentDate); }
} if (newConsulates[c].bestDate) {
if (newConsulates[c].bestDate) { let el = document.getElementById(`bestDate-${cId}`);
let el = document.getElementById(`bestDate-${c}`); if (el && el.innerText != newConsulates[c].bestDate)
if (el && el.innerText != newConsulates[c].bestDate) smoothTextChange(el, newConsulates[c].bestDate);
smoothTextChange(el, newConsulates[c].bestDate);
}
} }
} }
}); });