Survey view

This commit is contained in:
Andrea Marchesini
2025-09-30 17:48:00 +02:00
parent adbf310a17
commit 0eb13f214d
6 changed files with 114 additions and 11 deletions
+30 -1
View File
@@ -257,6 +257,8 @@ const messageHandler = {
browser.browserAction.setBadgeBackgroundColor({color: "rgba(0,217,0,255)"});
browser.browserAction.setBadgeText({text: "NEW"});
}
this.maybePrepareSurveyAchievementOnUpdate(countOfContainerTabsOpened);
},
async onFocusChangedCallback(windowId) {
@@ -273,7 +275,34 @@ const messageHandler = {
}).catch((e) => {
throw e;
});
}
},
async maybePrepareSurveyAchievementOnUpdate(countOpened) {
if (countOpened < 10) {
return;
}
// Show the survey only for English locales (en or en-*).
const uiLang = browser.i18n.getUILanguage();
const lang = (uiLang || "").toLowerCase();
if (lang !== "en" && !lang.startsWith("en-")) {
return;
}
// Check if already scheduled in the past; if so, do not show again.
const achievementsStorage = await browser.storage.local.get({ achievements: [] });
const achievements = achievementsStorage.achievements;
const existing = achievements.find(a => a.name === "survey");
if (existing) {
return;
}
// Ensure the achievement exists and is pending.
achievements.push({ name: "survey", done: false });
browser.storage.local.set({ achievements });
browser.browserAction.setBadgeBackgroundColor({color: "rgba(0,217,0,255)"});
browser.browserAction.setBadgeText({text: "NEW"});
},
};
// Lets do this last as theme manager did a check before connecting before