Skip to content

Commit

Permalink
Allow deletion of labels
Browse files Browse the repository at this point in the history
Close #7755

Co-authored-by: hrb-hub <181954414+hrb-hub@users.noreply.github.com>
  • Loading branch information
2 people authored and charlag committed Nov 21, 2024
1 parent 5f3e8a5 commit cf5bd4e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
34 changes: 21 additions & 13 deletions src/common/api/worker/facades/lazy/MailFacade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -55,6 +43,7 @@ import {
createEncryptedMailAddress,
createExternalUserData,
createListUnsubscribeData,
createManageLabelServiceDeleteIn,
createManageLabelServiceLabelData,
createManageLabelServicePostIn,
createMoveMailData,
Expand All @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions src/mail-app/mail/model/MailModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<MailFolder | null> {
const folderStructures = await this.loadMailSets()
for (const folders of folderStructures.values()) {
Expand Down
8 changes: 7 additions & 1 deletion src/mail-app/mail/view/MailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,13 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
this.showLabelEditDialog(label)
},
},
{ label: "delete_action", icon: Icons.Trash },
{
label: "delete_action",
icon: Icons.Trash,
click: () => {
this.mailViewModel.deleteLabel(label)
},
},
],
}),
})
Expand Down
4 changes: 4 additions & 0 deletions src/mail-app/mail/view/MailViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit cf5bd4e

Please sign in to comment.