Update currentDate in popup to "-" if date not found
This commit is contained in:
@@ -148,21 +148,19 @@ function smoothTextChange(element, newText) {
|
||||
consCfg[c].autoBook = e.target.checked;
|
||||
await chrome.storage.local.set({ "cfg_consulates": consCfg });
|
||||
});
|
||||
|
||||
// update current & best dates
|
||||
chrome.storage.onChanged.addListener((changes, area) => {
|
||||
if (changes.ctx_consulates) {
|
||||
const newConsulates = changes.ctx_consulates.newValue;
|
||||
let newCurrentDate = changes.ctx_consulates.newValue[c].currentDate || "-";
|
||||
let newBestDate = changes.ctx_consulates.newValue[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);
|
||||
}
|
||||
let el = document.getElementById(`currentDate-${cId}`);
|
||||
if (el && el.innerText != newCurrentDate)
|
||||
smoothTextChange(el, newCurrentDate);
|
||||
el = document.getElementById(`bestDate-${cId}`);
|
||||
if (el && el.innerText != newBestDate)
|
||||
smoothTextChange(el, newBestDate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user