Browse Source

Update sidebar content when local storage changes

jherve 1 year ago
parent
commit
eea8bc8539
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/sidebar.js

+ 6 - 1
src/sidebar.js

@@ -40,10 +40,15 @@ function createListOfJobs (jobs) {
     return ul;
 }
 
-(async () => {
+async function updateContent () {
     const content = document.querySelector("#content");
     const allJobs = Object.entries(await browser.storage.local.get()).map(a => a[1]);
     const stillToApplyJobs = allJobs.filter(j => j.application_date === null && j.application_considered);
 
     content.innerHTML = createListOfJobs(stillToApplyJobs).innerHTML;
+}
+
+(async () => {
+    updateContent();
+    browser.storage.local.onChanged.addListener(updateContent);
 })();