diff --git a/src/common/api/worker/facades/lazy/MailFacade.ts b/src/common/api/worker/facades/lazy/MailFacade.ts index af3c0706d96..8d7ed35c663 100644 --- a/src/common/api/worker/facades/lazy/MailFacade.ts +++ b/src/common/api/worker/facades/lazy/MailFacade.ts @@ -28,20 +28,8 @@ import { ReportedMailFieldType, SYSTEM_GROUP_MAIL_ADDRESS, } from "../../../common/TutanotaConstants.js" -import type { - Contact, - DraftAttachment, - DraftRecipient, - EncryptedMailAddress, - File as TutanotaFile, - InternalRecipientKeyData, - Mail, - MailFolder, - ReportedMailFieldMarker, - SendDraftData, - SymEncInternalRecipientKeyData, -} from "../../../entities/tutanota/TypeRefs.js" import { + Contact, createAttachmentKeyData, createCreateExternalUserGroupData, createCreateMailFolderData, @@ -55,6 +43,7 @@ import { createEncryptedMailAddress, createExternalUserData, createListUnsubscribeData, + createManageLabelServiceDeleteIn, createManageLabelServiceLabelData, createManageLabelServicePostIn, createMoveMailData, @@ -63,12 +52,22 @@ import { createSecureExternalRecipientKeyData, createSendDraftData, createUpdateMailFolderData, + DraftAttachment, + DraftRecipient, + EncryptedMailAddress, + File as TutanotaFile, FileTypeRef, + InternalRecipientKeyData, InternalRecipientKeyDataTypeRef, + Mail, MailDetails, MailDetailsBlobTypeRef, MailDetailsDraftTypeRef, + MailFolder, MailTypeRef, + ReportedMailFieldMarker, + SendDraftData, + SymEncInternalRecipientKeyData, SymEncInternalRecipientKeyDataTypeRef, TutanotaPropertiesTypeRef, } from "../../../entities/tutanota/TypeRefs.js" @@ -1072,6 +1071,15 @@ export class MailFacade { await this.entityClient.update(label) } } + + async deleteLabel(label: MailFolder) { + await this.serviceExecutor.delete( + ManageLabelService, + createManageLabelServiceDeleteIn({ + label: label._id, + }), + ) + } } export function phishingMarkerValue(type: ReportedMailFieldType, value: string): string { diff --git a/src/mail-app/mail/model/MailModel.ts b/src/mail-app/mail/model/MailModel.ts index 4f5a8f5a2bd..74dc1343f7c 100644 --- a/src/mail-app/mail/model/MailModel.ts +++ b/src/mail-app/mail/model/MailModel.ts @@ -538,6 +538,10 @@ export class MailModel { await this.mailFacade.updateLabel(label, newData.name, newData.color) } + async deleteLabel(label: MailFolder) { + await this.mailFacade.deleteLabel(label) + } + async getFolderById(folderElementId: Id): Promise { const folderStructures = await this.loadMailSets() for (const folders of folderStructures.values()) { diff --git a/src/mail-app/mail/view/MailView.ts b/src/mail-app/mail/view/MailView.ts index 7f8880e8edb..1b77b353e81 100644 --- a/src/mail-app/mail/view/MailView.ts +++ b/src/mail-app/mail/view/MailView.ts @@ -828,7 +828,13 @@ export class MailView extends BaseTopLevelView implements TopLevelView { + this.mailViewModel.deleteLabel(label) + }, + }, ], }), }) diff --git a/src/mail-app/mail/view/MailViewModel.ts b/src/mail-app/mail/view/MailViewModel.ts index 2b3e0191b27..6029f6dec5c 100644 --- a/src/mail-app/mail/view/MailViewModel.ts +++ b/src/mail-app/mail/view/MailViewModel.ts @@ -831,4 +831,8 @@ export class MailViewModel { async editLabel(label: MailFolder, newData: { name: string; color: string }) { await this.mailModel.updateLabel(label, newData) } + + async deleteLabel(label: MailFolder) { + await this.mailModel.deleteLabel(label) + } }