Skip to content

Commit 6e432ad

Browse files
committed
create a new draft when editing draft is scheduled in another client
close #295
1 parent 32aed0c commit 6e432ad

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/common/mailFunctionality/SendMailModel.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,10 +1150,12 @@ export class SendMailModel {
11501150
this._draftSavedRecently = true
11511151
this.waitUntilSync = false
11521152

1153+
//load the updated mail to check if the draft is already scheduled in another client
1154+
const upToDateDraft = this.draft && (await this.entity.load(MailTypeRef, this.draft._id))
11531155
this.draft =
1154-
this.draft == null || (await this.needNewDraft(this.draft))
1156+
upToDateDraft == null || (await this.needNewDraft(upToDateDraft))
11551157
? await this.createDraft(body, attachments, mailMethod)
1156-
: await this.updateDraft(body, attachments, this.draft)
1158+
: await this.updateDraft(body, attachments, upToDateDraft)
11571159

11581160
const attachmentIds = await this.mailFacade.getAttachmentIds(this.draft)
11591161
const newAttachments = await promiseMap(attachmentIds, (fileId) => this.entity.load<TutanotaFile>(FileTypeRef, fileId), {

src/mail-app/mailLocator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ import { MailModel } from "./mail/model/MailModel.js"
124124
import type { CommonLocator } from "../common/api/main/CommonLocator.js"
125125
import { WorkerRandomizer } from "../common/api/worker/workerInterfaces.js"
126126
import { WorkerInterface } from "./workerUtils/worker/WorkerImpl.js"
127-
import { isMailInSpamOrTrash } from "./mail/model/MailChecks.js"
127+
import { isEditableDraft, isMailInSpamOrTrash } from "./mail/model/MailChecks.js"
128128
import type { ContactImporter } from "./contacts/ContactImporter.js"
129129
import { ExternalCalendarFacade } from "../common/native/common/generatedipc/ExternalCalendarFacade.js"
130130
import { AppType } from "../common/misc/ClientConstants.js"
@@ -460,7 +460,7 @@ class MailLocator implements CommonLocator {
460460
mailboxProperties,
461461
this.autosaveFacade,
462462
async (mail: Mail) => {
463-
return await isMailInSpamOrTrash(mail, mailLocator.mailModel)
463+
return !isEditableDraft(mail) || (await isMailInSpamOrTrash(mail, mailLocator.mailModel))
464464
},
465465
this.syncTracker,
466466
)

0 commit comments

Comments
 (0)