Rework composer draft management
Currently, Geary uses the remote server when saving drafts. This is somewhat impractical, since people may be writing email offline, since saving messages with large attachments takes a long time and use a lot of bandwidth to upload, since it exacerbates server bugs like those in GMail and limitations like those without UID plus support, and makes auto-save and undo of deleted messages somewhat difficult to reliably implement.
Instead, Geary should use the local draft folder when saving drafts as they change, and only upload to the server when composer is closed (if online) or during draft folder sync. In any case, when closing a composer, a draft should always be saved automatically and an inline-notification displayed allowing the composer to be restored. The Save button can be removed, and the Trash button saves and notifies, but marks the draft as locally deleted, so it is no longer appears in the folder or in conversations.
Undo can be implemented by simply re-loading the draft from the local folder, and undoing Trash by unmarking the local message as deleted, and possibly by keeping a copy of the message in memory to restore from, in case the deleted message is trashed by folder sync.
Work involved is something like:
-
Update composer to simply save directly to a folder object -
Remove App.DraftManager -
Special-case the folder implementation for Drafts, to make it delay upload of changed messages -
Add support for uploading on folder open/sync -
Add support to allow composer to explicitly request folder/email sync -
Implement undo support for closing and trash-close for the composer -
Remove code for handing confirmation on composer close
TODO: Work out how this interacts with the persistent composer idea