@@ -28,7 +28,7 @@ import { locator } from "../api/main/CommonLocator"
2828import { SwitchAccountTypeService } from "../api/entities/sys/Services.js"
2929import { BadRequestError , InvalidDataError , PreconditionFailedError } from "../api/common/error/RestError.js"
3030import { PaymentInterval , PriceAndConfigProvider } from "./utils/PriceUtils"
31- import { assertNotNull , base64ExtToBase64 , base64ToUint8Array , delay , downcast , lazy } from "@tutao/tutanota-utils"
31+ import { assertNotNull , base64ExtToBase64 , base64ToUint8Array , defer , delay , downcast , lazy } from "@tutao/tutanota-utils"
3232import { showSwitchToBusinessInvoiceDataDialog } from "./SwitchToBusinessInvoiceDataDialog.js"
3333import { getByAbbreviation } from "../api/common/CountryList.js"
3434import { formatNameAndAddress } from "../api/common/utils/CommonFormatter.js"
@@ -83,7 +83,9 @@ export async function showSwitchDialog({
8383 PriceAndConfigProvider . getInitializedInstance ( null , locator . serviceExecutor , null ) ,
8484 )
8585 const model = new SwitchSubscriptionDialogModel ( customer , accountingInfo , await locator . logins . getUserController ( ) . getPlanType ( ) , lastBooking )
86+ const deferred = defer < void > ( )
8687 const cancelAction = ( ) => {
88+ deferred . resolve ( )
8789 dialog . close ( )
8890 }
8991
@@ -199,7 +201,7 @@ export async function showSwitchDialog({
199201 [ PlanType . Unlimited ] : createPlanButton ( dialog , PlanType . Unlimited , currentPlanInfo , paymentInterval , accountingInfo ) ,
200202 }
201203 dialog . show ( )
202- return
204+ return deferred . promise
203205}
204206
205207async function onSwitchToFree ( customer : Customer , dialog : Dialog , currentPlanInfo : CurrentPlanInfo ) {
@@ -505,6 +507,6 @@ async function switchSubscription(targetSubscription: PlanType, dialog: Dialog,
505507 throw e
506508 }
507509 } finally {
508- dialog . close ( )
510+ dialog . onClose ( )
509511 }
510512}
0 commit comments