diff --git a/bun.lockb b/bun.lockb index c4de321..5a6c51f 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/dist/style.css b/dist/style.css index 37bcb20..6c89209 100644 --- a/dist/style.css +++ b/dist/style.css @@ -107,7 +107,7 @@ } /* -! tailwindcss v3.4.16 | MIT License | https://tailwindcss.com +! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com */ /* @@ -2231,8 +2231,7 @@ input.tab:checked + .tab-content, .progress::-moz-progress-bar { border-radius: var(--rounded-box, 1rem); - --tw-bg-opacity: 1; - background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity))); + background-color: currentColor; } .progress:indeterminate { @@ -2256,8 +2255,7 @@ input.tab:checked + .tab-content, .progress::-webkit-progress-value { border-radius: var(--rounded-box, 1rem); - --tw-bg-opacity: 1; - background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity))); + background-color: currentColor; } .progress:indeterminate::-moz-progress-bar { diff --git a/inc/background.js b/inc/background.js index eec94e1..af0476d 100644 --- a/inc/background.js +++ b/inc/background.js @@ -1,17 +1,25 @@ const bg = { init: function () { icingaData.init(); - bg.refresh(); if (typeof chrome !== 'undefined') { - chrome.alarms.onAlarm.addListener(() => { - bg.refresh(); - }); + chrome.alarms.onAlarm.removeListener(bg.refreshAlarm); + chrome.alarms.onAlarm.addListener(bg.refreshAlarm); } else { - browser.alarms.onAlarm.addListener(() => { - bg.refresh(); - }); + browser.alarms.onAlarm.removeListener(bg.refreshAlarm); + browser.alarms.onAlarm.addListener(bg.refreshAlarm); + } + + bg.refresh(); + }, + + // Refresh method for alarm + refreshAlarm: function (alarm) { + if (alarm.name !== 'icinga-refresh') { + return; } + + bg.refresh(); }, // Refresh data for all icinga instances @@ -38,9 +46,21 @@ const bg = { let interval_in_seconds = (settings.refresh === undefined) ? 30 : settings.refresh; let interval_in_minutes = interval_in_seconds / 60; if (typeof chrome !== 'undefined') { - chrome.alarms.create('icinga-refresh', {delayInMinutes: interval_in_minutes}); + chrome.alarms.get('icinga-refresh', alarm => { + if (alarm) { + return; + } + + chrome.alarms.create('icinga-refresh', {delayInMinutes: interval_in_minutes}); + }); } else { - browser.alarms.create('icinga-refresh', {delayInMinutes: interval_in_minutes}); + browser.alarms.get('icinga-refresh', alarm => { + if (alarm) { + return; + } + + browser.alarms.create('icinga-refresh', {delayInMinutes: interval_in_minutes}); + }); } }); }, diff --git a/inc/background_script.js b/inc/background_script.js index 520e4d2..b0ca9e5 100644 --- a/inc/background_script.js +++ b/inc/background_script.js @@ -1,2 +1,32 @@ +function isExtensionStartup() { + if (!browser.storage.session) return Promise.resolve(true); + return new Promise(resolve => { + return browser.storage.session.get('hasAlreadyStarted', v => { + resolve(v.hasAlreadyStarted !== true); + }); + }); +} -bg.init(); +function setHasAlreadyStarted() { + if (!browser.storage.session) return; + browser.storage.session.set({ + hasAlreadyStarted: true, + }); +} + +browser.runtime.onStartup.addListener(() => { + bg.init(); +}); + +browser.runtime.onInstalled.addListener(details => { + if (details.reason === 'install' || details.reason === 'update') { + bg.init(); + } +}); + +isExtensionStartup().then(isStartup => { + if (isStartup) { + bg.init(); + setHasAlreadyStarted(); + } +}); diff --git a/inc/service_worker.js b/inc/service_worker.js index 8c35654..cf5a1d9 100644 --- a/inc/service_worker.js +++ b/inc/service_worker.js @@ -2,4 +2,36 @@ importScripts('icinga.js'); importScripts('data.js'); importScripts('background.js'); -bg.init(); +function isExtensionStartup() { + if (!chrome.storage.session) return Promise.resolve(true); + return new Promise(resolve => { + return chrome.storage.session.get('hasAlreadyStarted', v => { + resolve(v.hasAlreadyStarted !== true); + }); + }); +} + +function setHasAlreadyStarted() { + if (!chrome.storage.session) return; + chrome.storage.session.set({ + hasAlreadyStarted: true, + }); +} + +chrome.runtime.onStartup.addListener(() => { + bg.init(); +}); + +chrome.runtime.onInstalled.addListener(details => { + if (details.reason === 'install' || details.reason === 'update') { + bg.init(); + } +}); + +isExtensionStartup().then(isStartup => { + if (isStartup) { + bg.init(); + setHasAlreadyStarted(); + } +}); + diff --git a/manifest.json b/manifest.json index 14fbce8..67d147b 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Icinga Multi Status", "short_name": "Icinga Multi Status", - "version": "1.0.2", + "version": "1.0.3", "description": "Icinga Multi Status helps you monitor your Icinga instances with alert badges and notifications about incidents.", "author": "Daniel Schmitz, bashgeek.net", diff --git a/package.json b/package.json index 2f5399c..7c076c8 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "build": "npx tailwindcss -i ./src/style.css -o ./dist/style.css" }, "devDependencies": { - "daisyui": "^4.12.20", - "tailwindcss": "^3.4.16" + "daisyui": "^4.12.22", + "tailwindcss": "^3.4.17" } }