Skip to content

MailComposer: Save draft in correct folder (#646) #647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jermy-c
Copy link
Collaborator

@jermy-c jermy-c commented May 30, 2025

  • Emails were saving to the initial identity even when the identity is changed
  • The mail.folder is now set before saving

@jermy-c jermy-c requested a review from benbucksch May 30, 2025 22:14
@jermy-c jermy-c self-assigned this May 30, 2025
@jermy-c jermy-c linked an issue May 30, 2025 that may be closed by this pull request
Copy link
Collaborator

@benbucksch benbucksch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead, in line 241, change ??= to = .

Test various scenarios to make sure it doesn't regress something.

@jermy-c
Copy link
Collaborator Author

jermy-c commented Jun 4, 2025

Instead, in line 241, change ??= to = .

This works.

I'm getting some errors when deleting the saved draft for EWS. And it seems to be saving a new copy if you're editing the draft.

  1. this.folder.account.callEWS is not a function
  2. The specified object was not found in the store., The process failed to get the correct properties.

@benbucksch
Copy link
Collaborator

Are these bugs new regressions from this change here?

I suspect that we need to check whether the folder changed, and delete the old draft from the old folder.

@jermy-c
Copy link
Collaborator Author

jermy-c commented Jun 4, 2025

Are these bugs new regressions from this change here?

Yes, it seems to be caused by the folder change.

I suspect that we need to check whether the folder changed, and delete the old draft from the old folder.

Ok, I'll try this.

@NeilRashbrook
Copy link
Collaborator

Once you edit a draft, you're changing an email which thinks it knows what its folder and account are, and doesn't take very kindly to having these things changed for it. For instance, the draft folder still has the draft email in its messages list.

From my point of view the ideal solution would be to clone the email and edit that instead, keeping a reference to the original email so that it can be deleted (seems simpler than looking for it).

@jermy-c
Copy link
Collaborator Author

jermy-c commented Jun 6, 2025

  • We were saving the email based on folder.account rather than identity.account, however, our identity.account and folder.account don't match. That's for the saving the email in the wrong identity.

let account = this.email.folder?.account ?? this.email.identity?.account;

  • For the body, we don't regenerate the MIME for the email so edits were not saved.

message.mime ??= await CreateMIME.getMIME(message);

@benbucksch
Copy link
Collaborator

benbucksch commented Jun 11, 2025

[when opening a draft,] clone the [draft] email and edit that instead, keeping a reference to the original [draft] email so that it can be deleted.

Makes sense. Let's do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mail: Draft is not save in the selected identity folder
3 participants