Survey view
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user