Revert "Merge pull request #2803 from mozilla/survey"
This reverts commitc34c1c1e04, reversing changes made toadbf310a17.
This commit is contained in:
@@ -257,8 +257,6 @@ const messageHandler = {
|
||||
browser.browserAction.setBadgeBackgroundColor({color: "rgba(0,217,0,255)"});
|
||||
browser.browserAction.setBadgeText({text: "NEW"});
|
||||
}
|
||||
|
||||
this.maybePrepareSurveyAchievementOnUpdate(countOfContainerTabsOpened);
|
||||
},
|
||||
|
||||
async onFocusChangedCallback(windowId) {
|
||||
@@ -275,33 +273,7 @@ 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 shown in the past; if so, do not show again.
|
||||
const { achievements } = await browser.storage.local.get({ 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
|
||||
|
||||
+9
-39
@@ -31,7 +31,6 @@ const P_CONTAINER_INFO = "containerInfo";
|
||||
const P_CONTAINER_EDIT = "containerEdit";
|
||||
const P_CONTAINER_DELETE = "containerDelete";
|
||||
const P_CONTAINERS_ACHIEVEMENT = "containersAchievement";
|
||||
const P_SURVEY_ACHIEVEMENT = "surveyAchievement";
|
||||
const P_CONTAINER_ASSIGNMENTS = "containerAssignments";
|
||||
const P_CLEAR_CONTAINER_STORAGE = "clearContainerStorage";
|
||||
|
||||
@@ -139,23 +138,18 @@ const Logic = {
|
||||
|
||||
async showAchievementOrContainersListPanel() {
|
||||
// Do we need to show an achievement panel?
|
||||
let showAchievements = false;
|
||||
const achievementsStorage = await browser.storage.local.get({ achievements: [] });
|
||||
const pending = achievementsStorage.achievements.filter(a => !a.done);
|
||||
|
||||
if (pending.length) {
|
||||
// Prefer showing the survey view first if present, otherwise fall back
|
||||
// to the existing achievement panel.
|
||||
const survey = pending.find(a => a.name === "survey");
|
||||
if (survey) {
|
||||
this.showPanel(P_SURVEY_ACHIEVEMENT);
|
||||
return;
|
||||
for (const achievement of achievementsStorage.achievements) {
|
||||
if (!achievement.done) {
|
||||
showAchievements = true;
|
||||
}
|
||||
|
||||
this.showPanel(P_CONTAINERS_ACHIEVEMENT);
|
||||
return;
|
||||
}
|
||||
|
||||
this.showPanel(P_CONTAINERS_LIST);
|
||||
if (showAchievements) {
|
||||
this.showPanel(P_CONTAINERS_ACHIEVEMENT);
|
||||
} else {
|
||||
this.showPanel(P_CONTAINERS_LIST);
|
||||
}
|
||||
},
|
||||
|
||||
// In case the user wants to click multiple actions,
|
||||
@@ -2382,30 +2376,6 @@ Logic.registerPanel(P_CONTAINERS_ACHIEVEMENT, {
|
||||
},
|
||||
});
|
||||
|
||||
// P_SURVEY_ACHIEVEMENT: A simple survey view.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Logic.registerPanel(P_SURVEY_ACHIEVEMENT, {
|
||||
panelSelector: ".survey-panel",
|
||||
|
||||
// This method is called when the object is registered.
|
||||
initialize() {
|
||||
Utils.addEnterHandler(document.querySelector("#survey-achievement-done-button"), async () => {
|
||||
await Logic.setAchievementDone("survey");
|
||||
Logic.showPanel(P_CONTAINERS_LIST);
|
||||
});
|
||||
Utils.addEnterHandler(document.querySelector("#survey-button"), async () => {
|
||||
await Logic.setAchievementDone("survey");
|
||||
window.close();
|
||||
});
|
||||
},
|
||||
|
||||
// This method is called when the panel is shown.
|
||||
prepare() {
|
||||
return Promise.resolve(null);
|
||||
},
|
||||
});
|
||||
|
||||
Logic.init();
|
||||
|
||||
window.addEventListener("resize", function () {
|
||||
|
||||
Reference in New Issue
Block a user