From 90a58961d40c94b369e05ecfc4160ca7f037d40b Mon Sep 17 00:00:00 2001 From: Maks Snegov Date: Sat, 27 Apr 2024 22:46:50 -0700 Subject: [PATCH] Fix live current & best dates in popup --- popup/popup.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/popup/popup.js b/popup/popup.js index 66733d8..a34132e 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -150,20 +150,18 @@ function smoothTextChange(element, newText) { }); // update current & best dates chrome.storage.onChanged.addListener((changes, area) => { - if (area === 'local' && changes.ctx_consulates) { + if (changes.ctx_consulates) { const newConsulates = changes.ctx_consulates.newValue; - for (let c in newConsulates) { - if (newConsulates[c].currentDate) { - let el = document.getElementById(`currentDate-${c}`); - if (el && el.innerText != newConsulates[c].currentDate) - smoothTextChange(el, newConsulates[c].currentDate); - } - if (newConsulates[c].bestDate) { - let el = document.getElementById(`bestDate-${c}`); - if (el && el.innerText != newConsulates[c].bestDate) - smoothTextChange(el, newConsulates[c].bestDate); - } + if (newConsulates[c].currentDate) { + let el = document.getElementById(`currentDate-${cId}`); + if (el && el.innerText != newConsulates[c].currentDate) + smoothTextChange(el, newConsulates[c].currentDate); + } + if (newConsulates[c].bestDate) { + let el = document.getElementById(`bestDate-${cId}`); + if (el && el.innerText != newConsulates[c].bestDate) + smoothTextChange(el, newConsulates[c].bestDate); } } });