Prevent the plan dialog from opening multiple times

Close #8868
This commit is contained in:
wrd 2025-10-16 13:51:42 +02:00 committed by paw
parent 9100edc7b8
commit c33c24053e

View file

@ -9,10 +9,16 @@ import { GENERATED_MAX_ID } from "../api/common/utils/EntityUtils.js"
import { AvailablePlanType, Const, NewBusinessPlans, NewPaidPlans, NewPersonalPlans, PlanType } from "../api/common/TutanotaConstants.js"
import { ProgrammingError } from "../api/common/error/ProgrammingError.js"
let upgradeDialogShowing = false
/**
* Opens a dialog which states that the function is not available in the Free subscription and provides an option to upgrade.
*/
export async function showNotAvailableForFreeDialog(acceptedPlans: readonly AvailablePlanType[] = NewPaidPlans) {
// upgradeDialogShowing prevents the dialog from being opened multiple times, as could happen when waiting for the wizard to import
if (!upgradeDialogShowing) {
upgradeDialogShowing = true
try {
const wizard = await import("../subscription/UpgradeSubscriptionWizard")
const customerInfo = await locator.logins.getUserController().loadCustomerInfo()
@ -21,7 +27,16 @@ export async function showNotAvailableForFreeDialog(acceptedPlans: readonly Avai
NewPersonalPlans.includes(downcast(customerInfo.plan))
const msg = lang.getTranslation(businessPlanRequired ? "pricing.notSupportedByPersonalPlan_msg" : "newPaidPlanRequired_msg")
await wizard.showUpgradeWizard({ logins: locator.logins, isCalledBySatisfactionDialog: false, acceptedPlans, msg })
await wizard.showUpgradeWizard({
logins: locator.logins,
isCalledBySatisfactionDialog: false,
acceptedPlans,
msg,
})
} finally {
upgradeDialogShowing = false
}
}
}
export function createNotAvailableForFreeClickHandler(