mirror of
https://github.com/tutao/tutanota.git
synced 2025-12-07 13:49:47 +00:00
Handle alias deactivation failure due to alias having scheduled mails
This commit is contained in:
parent
6b9da713b9
commit
558f2d27c5
5 changed files with 35 additions and 3 deletions
|
|
@ -2135,3 +2135,4 @@ export type TranslationKeyType =
|
|||
| "invalidSendLaterDate_msg"
|
||||
| "sendTime_label"
|
||||
| "removeScheduledMails_msg"
|
||||
| "aliasDeactivationNotPossible_msg"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { Dialog } from "../../gui/base/Dialog.js"
|
|||
import type { TableLineAttrs } from "../../gui/base/Table.js"
|
||||
import { ColumnWidth, Table } from "../../gui/base/Table.js"
|
||||
import { lang, TranslationKey } from "../../misc/LanguageViewModel.js"
|
||||
import { LimitReachedError } from "../../api/common/error/RestError.js"
|
||||
import { LimitReachedError, PreconditionFailedError } from "../../api/common/error/RestError.js"
|
||||
import { ofClass } from "@tutao/tutanota-utils"
|
||||
import { Icons } from "../../gui/base/icons/Icons.js"
|
||||
import { showProgressDialog } from "../../gui/dialogs/ProgressDialog.js"
|
||||
|
|
@ -17,6 +17,7 @@ import { AddressInfo, AddressStatus, MailAddressTableModel } from "./MailAddress
|
|||
import { showAddAliasDialog } from "./AddAliasDialog.js"
|
||||
import { locator } from "../../api/main/CommonLocator.js"
|
||||
import { UpgradeRequiredError } from "../../api/main/UpgradeRequiredError.js"
|
||||
import { UnsubscribeFailureReason } from "../../api/common/TutanotaConstants"
|
||||
|
||||
assertMainOrNode()
|
||||
|
||||
|
|
@ -209,6 +210,7 @@ async function switchAliasStatus(alias: AddressInfo, attrs: MailAddressTableAttr
|
|||
|
||||
const updateModel = attrs.model
|
||||
.setAliasStatus(alias.address, !deactivateOrDeleteAlias)
|
||||
.catch(ofClass(PreconditionFailedError, handleSetAliasStatusPreconditionFailed))
|
||||
.catch(ofClass(LimitReachedError, () => attrs.model.handleTooManyAliases()))
|
||||
.catch(ofClass(UpgradeRequiredError, (e) => showPlanUpgradeRequiredDialog(e.plans, e.message)))
|
||||
await showProgressDialog("pleaseWait_msg", updateModel)
|
||||
|
|
@ -226,3 +228,28 @@ function showSenderNameChangeDialog(model: MailAddressTableModel, alias: { addre
|
|||
defaultValue: alias.name,
|
||||
}).then((newName) => showProgressDialog("pleaseWait_msg", model.setAliasName(alias.address, newName)))
|
||||
}
|
||||
|
||||
function handleSetAliasStatusPreconditionFailed(e: PreconditionFailedError): void {
|
||||
const reason = e.data
|
||||
|
||||
if (reason == null) {
|
||||
Dialog.message("unknownError_msg")
|
||||
} else {
|
||||
let detailMsg: string
|
||||
|
||||
switch (reason) {
|
||||
case UnsubscribeFailureReason.HAS_SCHEDULED_MAILS:
|
||||
detailMsg = lang.getTranslationText("removeScheduledMails_msg")
|
||||
break
|
||||
|
||||
default:
|
||||
throw e
|
||||
}
|
||||
|
||||
Dialog.message(
|
||||
lang.getTranslation("aliasDeactivationNotPossible_msg", {
|
||||
"{detailMsg}": detailMsg,
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2136,6 +2136,7 @@ export default {
|
|||
"switchScheduledFolder_action": "Switch to scheduled folder",
|
||||
"invalidSendLaterDate_msg": "Invalid send later date",
|
||||
"sendTime_label": "Send time",
|
||||
"removeScheduledMails_msg": "Please remove your scheduled mails."
|
||||
"removeScheduledMails_msg": "Please remove your scheduled mails.",
|
||||
"aliasDeactivationNotPossible_msg": "Could not deactivate alias. {detailMsg}"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2136,5 +2136,7 @@ export default {
|
|||
"switchScheduledFolder_action": "Switch to scheduled folder",
|
||||
"invalidSendLaterDate_msg": "Invalid send later date",
|
||||
"sendTime_label": "Send time",
|
||||
"removeScheduledMails_msg": "Please remove your scheduled mails.",
|
||||
"aliasDeactivationNotPossible_msg": "Could not deactivate alias. {detailMsg}"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2136,6 +2136,7 @@ export default {
|
|||
"switchScheduledFolder_action": "Switch to scheduled folder",
|
||||
"invalidSendLaterDate_msg": "Invalid send later date",
|
||||
"sendTime_label": "Send time",
|
||||
"removeScheduledMails_msg": "Please remove your scheduled mails."
|
||||
"removeScheduledMails_msg": "Please remove your scheduled mails.",
|
||||
"aliasDeactivationNotPossible_msg": "Could not deactivate alias. {detailMsg}"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue