perf: throttle theme update check to daily and remove redundant cloud poll on page load

This commit is contained in:
SethBurkart123
2026-04-20 15:39:37 +10:00
parent 3702443ece
commit 01eeb18638
2 changed files with 8 additions and 4 deletions
-4
View File
@@ -59,10 +59,6 @@ async function init() {
IsSEQTAPage = true; IsSEQTAPage = true;
console.info("[BetterSEQTA+] Verified SEQTA Page"); console.info("[BetterSEQTA+] Verified SEQTA Page");
if (typeof window !== "undefined" && window === window.top) {
void browser.runtime.sendMessage({ type: "cloudSettingsPoll" }).catch(() => {});
}
registerFetchSeqtaAppLinkListener(); registerFetchSeqtaAppLinkListener();
const documentLoadStyle = document.createElement("style"); const documentLoadStyle = document.createElement("style");
@@ -680,9 +680,17 @@ export class ThemeManager {
* Compare installed store themes to GET /api/themes and refresh when the server is newer. * Compare installed store themes to GET /api/themes and refresh when the server is newer.
* Skips themes with userEdited: true (theme creator / popup save, or custom accent vs default). * Skips themes with userEdited: true (theme creator / popup save, or custom accent vs default).
*/ */
private static STORE_CHECK_KEY = "bsplus_lastStoreThemeCheck";
private static STORE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000; // 24 hours
public async checkStoreThemeUpdates(): Promise<void> { public async checkStoreThemeUpdates(): Promise<void> {
if (this.storeUpdateCheckRunning) return; if (this.storeUpdateCheckRunning) return;
const lastCheck = Number(localStorage.getItem(ThemeManager.STORE_CHECK_KEY) || 0);
if (Date.now() - lastCheck < ThemeManager.STORE_CHECK_INTERVAL_MS) return;
this.storeUpdateCheckRunning = true; this.storeUpdateCheckRunning = true;
localStorage.setItem(ThemeManager.STORE_CHECK_KEY, String(Date.now()));
try { try {
const token = await cloudAuth.getStoredToken(); const token = await cloudAuth.getStoredToken();
const res = (await browser.runtime.sendMessage({ const res = (await browser.runtime.sendMessage({