Skip to content
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

Mail Composer: Save draft #407

Closed
Tracked by #392
benbucksch opened this issue Jan 17, 2025 · 11 comments
Closed
Tracked by #392

Mail Composer: Save draft #407

benbucksch opened this issue Jan 17, 2025 · 11 comments
Assignees
Labels

Comments

@benbucksch
Copy link
Collaborator

No description provided.

@benbucksch
Copy link
Collaborator Author

See EMail.ts line 610.

What happens is that JPC observe() function tries to serialize the entire object tree, starting with the email.folder and email.identity, and walking folder.messages, and serializing all messages. Obviously, that doesn't make sense.

@benbucksch
Copy link
Collaborator Author

@NeilRashbrook Could you help me out here, please? I'm stuck on this.

@NeilRashbrook
Copy link
Collaborator

NeilRashbrook commented Jan 17, 2025

You shouldn't be sending an email object across IPC. To generate MIME for a message, use await SMTPAccount.getMIME(email);. See

Mime: await SMTPAccount.getMIME(email),

observe() is a red herring; this would also happen with an object that doesn't support Svelte directly in createObjectDescription.

When sending an object across JPC, in order to accurately represent the object, all of its own properties also get sent, unless they begin with _, as those are assumed to be backing values for getters. Examples of own properties on the EMail object are to, cc, bcc, attachments, tags, headers, folder, storageLock, identity.

@NeilRashbrook
Copy link
Collaborator

(I don't know what happened to that link, it looked fine in preview.)

Mime: await SMTPAccount.getMIME(email),

@NeilRashbrook
Copy link
Collaborator

We haven't run into this before because none of our front end calls pass classes as parameters and most of them also return primitive values or plain objects. One obvious exception is our WebContents wrapper but that uses _win for its reference which avoids being serialised. I don't know about the other Node imports which we serialise from the backend to the front end (HTTPServer, ImapFlow, Database, Zip, shell, Tray, Notification, fs).

@NeilRashbrook
Copy link
Collaborator

Oh dear, circular reference time again...

@benbucksch
Copy link
Collaborator Author

benbucksch commented Jan 18, 2025

@NeilRashbrook Thanks, Neil, for the good patch. I've landed something very similar on master.

We still have one problem: If I drag a file (e.g. a PDF file) into the mail composer as attachment, then save as draft, it saves apparently correctly. I can open the file while viewing the draft as message in the viewer (click on the attachment icon to open it in a local app). I can even re-open the draft, using the [Edit Draft] button, and the attachment shows up correctly in the mail composer again. However, I can then neither send nor save as draft again. I get error:
"Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.
Add recipient" from CreateMIME.getAttachment().

@NeilRashbrook
Copy link
Collaborator

I get Error: MIME source not yet downloaded after which things go downhill rapidly.

@benbucksch
Copy link
Collaborator Author

benbucksch commented Jan 18, 2025

Ah, I didn't see that error message. Thanks. Then the cause and fix is clear: I need to run message.loadMIME() before opening it in the editor. I tried that and it works.

@benbucksch
Copy link
Collaborator Author

I've pushed the changes.

TODO: Draft does not get deleted on send, even though I try. There's something wrong with the message IDs, they don't match.

@benbucksch
Copy link
Collaborator Author

TODO: Draft does not get deleted on send, even though I try. There's something wrong with the message IDs, they don't match.

Filed #413 about that

@benbucksch benbucksch changed the title Save draft Mail Composer: Save draft Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants