Skip to content

Commit d8c769d

Browse files
committed
Fix language popup ordering on Linux/Windows
1 parent fbaf5a5 commit d8c769d

1 file changed

Lines changed: 74 additions & 66 deletions

File tree

src/main/electron/main.ts

Lines changed: 74 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,83 +2704,91 @@ function createHubWindow(state?: WindowState) {
27042704
firstLoad = false;
27052705

27062706
// Beta init
2707-
let allowLocalizationPopup = true;
2708-
if (isBeta()) {
2709-
if (isBetaExpired()) {
2710-
allowLocalizationPopup = false;
2711-
let expiredDetail = "";
2712-
if (isAlpha()) {
2713-
expiredDetail =
2714-
DISTRIBUTION === Distribution.WPILib
2715-
? t("main.survey.expiredAlphaWpilib")
2716-
: t("main.survey.expiredAlphaGithub");
2717-
} else {
2718-
expiredDetail =
2719-
DISTRIBUTION === Distribution.WPILib
2720-
? t("main.survey.expiredBetaWpilib")
2721-
: t("main.survey.expiredBetaGithub");
2722-
}
2723-
dialog
2724-
.showMessageBox(window, {
2725-
type: "info",
2726-
title: t("main.warnings.alert"),
2727-
message: isAlpha() ? t("main.survey.alphaComplete") : t("main.survey.betaComplete"),
2728-
detail: expiredDetail,
2729-
buttons: [t("main.buttons.quit"), t("main.buttons.ignore")],
2730-
defaultId: 0
2731-
})
2732-
.then((result) => {
2733-
if (result.response === 0) app.quit();
2734-
});
2735-
} else if (!isBetaWelcomeComplete()) {
2736-
if (lang === "en-US") {
2737-
// Skip beta welcome for non-English users, since there is a separate popup explaining how to provide feedback on translations (and we don't want to overwhelm the user with popups).
2738-
openBetaWelcome(window);
2707+
let showStartupPopups = () => {
2708+
let allowLocalizationPopup = true;
2709+
if (isBeta()) {
2710+
if (isBetaExpired()) {
2711+
allowLocalizationPopup = false;
2712+
let expiredDetail = "";
2713+
if (isAlpha()) {
2714+
expiredDetail =
2715+
DISTRIBUTION === Distribution.WPILib
2716+
? t("main.survey.expiredAlphaWpilib")
2717+
: t("main.survey.expiredAlphaGithub");
2718+
} else {
2719+
expiredDetail =
2720+
DISTRIBUTION === Distribution.WPILib
2721+
? t("main.survey.expiredBetaWpilib")
2722+
: t("main.survey.expiredBetaGithub");
2723+
}
2724+
dialog
2725+
.showMessageBox(window, {
2726+
type: "info",
2727+
title: t("main.warnings.alert"),
2728+
message: isAlpha() ? t("main.survey.alphaComplete") : t("main.survey.betaComplete"),
2729+
detail: expiredDetail,
2730+
buttons: [t("main.buttons.quit"), t("main.buttons.ignore")],
2731+
defaultId: 0
2732+
})
2733+
.then((result) => {
2734+
if (result.response === 0) app.quit();
2735+
});
2736+
} else if (!isBetaWelcomeComplete()) {
2737+
if (lang === "en-US") {
2738+
// Skip beta welcome for non-English users, since there is a separate popup explaining how to provide feedback on translations (and we don't want to overwhelm the user with popups).
2739+
openBetaWelcome(window);
2740+
}
2741+
} else if (shouldPromptBetaSurvey()) {
2742+
allowLocalizationPopup = false;
2743+
2744+
dialog
2745+
.showMessageBox(window, {
2746+
type: "info",
2747+
title: t("main.warnings.alert"),
2748+
message: t("main.survey.feedbackQuery"),
2749+
detail: isAlpha() ? t("main.survey.feedbackAlphaDetail") : t("main.survey.feedbackBetaDetail"),
2750+
buttons: [t("main.buttons.open"), t("main.survey.notNow")],
2751+
defaultId: 0
2752+
})
2753+
.then((result) => {
2754+
if (result.response === 0) {
2755+
openBetaSurvey();
2756+
} else {
2757+
delayBetaSurvey();
2758+
}
2759+
});
27392760
}
2740-
} else if (shouldPromptBetaSurvey()) {
2741-
allowLocalizationPopup = false;
2761+
}
27422762

2763+
// Localization feedback popup
2764+
let prefs: Preferences = jsonfile.readFileSync(PREFS_FILENAME);
2765+
if (lang !== "en-US" && !prefs.skipLanguageWarning && allowLocalizationPopup) {
27432766
dialog
27442767
.showMessageBox(window, {
27452768
type: "info",
27462769
title: t("main.warnings.alert"),
2747-
message: t("main.survey.feedbackQuery"),
2748-
detail: isAlpha() ? t("main.survey.feedbackAlphaDetail") : t("main.survey.feedbackBetaDetail"),
2749-
buttons: [t("main.buttons.open"), t("main.survey.notNow")],
2750-
defaultId: 0
2770+
message: t("main.language.welcomeMessage"),
2771+
detail: t("main.language.welcomeDetail"),
2772+
checkboxLabel: t("main.buttons.dontShowAgain"),
2773+
buttons: [t("main.buttons.ok")],
2774+
defaultId: 0,
2775+
icon: WINDOW_ICON
27512776
})
2752-
.then((result) => {
2753-
if (result.response === 0) {
2754-
openBetaSurvey();
2755-
} else {
2756-
delayBetaSurvey();
2777+
.then((response) => {
2778+
saveBetaWelcomeComplete(); // Mark beta welcome as complete so that the user doesn't get another popup later
2779+
if (response.checkboxChecked) {
2780+
prefs.skipLanguageWarning = true;
2781+
jsonfile.writeFileSync(PREFS_FILENAME, prefs);
2782+
sendAllPreferences();
27572783
}
27582784
});
27592785
}
2760-
}
2786+
};
27612787

2762-
// Localization feedback popup
2763-
let prefs: Preferences = jsonfile.readFileSync(PREFS_FILENAME);
2764-
if (lang !== "en-US" && !prefs.skipLanguageWarning && allowLocalizationPopup) {
2765-
dialog
2766-
.showMessageBox(window, {
2767-
type: "info",
2768-
title: t("main.warnings.alert"),
2769-
message: t("main.language.welcomeMessage"),
2770-
detail: t("main.language.welcomeDetail"),
2771-
checkboxLabel: t("main.buttons.dontShowAgain"),
2772-
buttons: [t("main.buttons.ok")],
2773-
defaultId: 0,
2774-
icon: WINDOW_ICON
2775-
})
2776-
.then((response) => {
2777-
saveBetaWelcomeComplete(); // Mark beta welcome as complete so that the user doesn't get another popup later
2778-
if (response.checkboxChecked) {
2779-
prefs.skipLanguageWarning = true;
2780-
jsonfile.writeFileSync(PREFS_FILENAME, prefs);
2781-
sendAllPreferences();
2782-
}
2783-
});
2788+
if (window.isVisible()) {
2789+
showStartupPopups();
2790+
} else {
2791+
window.once("show", showStartupPopups);
27842792
}
27852793
});
27862794
window.on("close", (event) => {

0 commit comments

Comments
 (0)