Closed
Bug 1498866
Opened 6 years ago
Closed 6 years ago
"Edit Template": template removed by Auto-save (implemented fix: keep template and manage auto-saved drafts)
Categories
(Thunderbird :: Message Compose Window, defect)
Tracking
(thunderbird_esr6063+ fixed, thunderbird63 wontfix, thunderbird64 fixed)
RESOLVED
FIXED
Thunderbird 64.0
People
(Reporter: jorgk-bmo, Assigned: jorgk-bmo)
References
Details
Attachments
(1 file, 4 obsolete files)
20.64 KB,
patch
|
aceman
:
review+
aceman
:
feedback+
jorgk-bmo
:
approval-comm-beta+
jorgk-bmo
:
approval-comm-esr60+
|
Details | Diff | Splinter Review |
+++ This bug was initially created as a clone of Bug #1498097 +++
STR:
Edit Template.
Wait for Auto-save.
Check the template folder, template is gone.
It comes back when the template is saved, but if the user sends or doesn't save, the template is lost.
Aceman came across this issue looking at bug 1498097.
Assignee | ||
Comment 1•6 years ago
|
||
Actually, the autosave saves it as draft, and the template gets removed.
Summary: "Edit Template": template removed by Auto-save → "Edit Template": template removed by Auto-save and saved as draft instead
Assignee | ||
Comment 2•6 years ago
|
||
OK, here are a few cases:
Edit template
wait, auto-save saves a draft, template deleted
Save template, draft is deleted, template saved
All OK.
Edit template
wait, auto-save saves a draft, template deleted
Close template without saving, draft is kept
Sort of OK, user can move the draft back to the templates folder
Edit template
wait, auto-save saves a draft, template deleted
Send (which is not the intended action here), draft is deleted, set message is kept
Sort of OK, user can move the draft back to the templates folder
Here are the problems:
1) When editing a template, we cannot auto-save intermediate versions into the template
folder since the user might want to cancel the edit. So auto-save must save a draft.
2) If auto-save saves a draft and leaves the original in the template folder, then
manually saving can only remove one message, not two. Well, that requires further investigation.
If we can only open one message, which one do we delete? The intermediate draft or the
original template? The result will always be that one copy too many.
Assignee | ||
Comment 3•6 years ago
|
||
Like for editing drafts, editing templates now carries around the "draft" ID, so the old one can be deleted:
https://hg.mozilla.org/comm-central/rev/5dd349d1efbc#l7.91
That the overall approach for drafts doesn't quite fit for templates can be seen in this bug.
Open to good ideas!!
Assignee | ||
Comment 4•6 years ago
|
||
Easiest way: Disable auto-save when editing a template. Auto-save is for editing new message and drafts where you don't want to lose all the content you're adding. Tweaking a template and losing this due to, well, power failure or some other sever incident, is not that big of a problem. I think the issue that auto-save causes when editing templates is more severe.
Assignee | ||
Comment 5•6 years ago
|
||
That's the best I can come up with.
Any other solution would involve more logic:
0) Detect auto-save during edit template and *not* delete the old version,
only save a draft.
1) Save after auto-save would have to delete the draft and the old template
and save the new version to the template folder.
The current design only allows to delete one message, not two.
2) Abort edit template after auto-save would have to delete the draft.
3) Send after auto-save could just delete the draft, the sent version
was never saved. The old template remains according to 0).
Attachment #9017044 -
Flags: feedback?(acelists)
(In reply to Jorg K (GMT+2) from comment #5)
> Created attachment 9017044 [details] [diff] [review]
> 1498866-no-auto-save-for-template.patch
>
> That's the best I can come up with.
>
> Any other solution would involve more logic:
> 0) Detect auto-save during edit template and *not* delete the old version,
> only save a draft.
Yes, this would be OK.
> 1) Save after auto-save would have to delete the draft and the old template
> and save the new version to the template folder.
> The current design only allows to delete one message, not two.
Why deleting the draft on Save? While the compose is open, it could still exist. Then the draft can be deleted upon send or close of composition.
> 2) Abort edit template after auto-save would have to delete the draft.
Yes.
> 3) Send after auto-save could just delete the draft, the sent version
> was never saved. The old template remains according to 0).
Yes, OK.
Assignee | ||
Comment 7•6 years ago
|
||
Thinking about this some more:
If you edit a draft and auto-save kicks in, you lose the previous version. So all we should do for edit template is auto-save the new version to the template folder, and done. That will eliminate all problems. We've already fixed bug 1498097 where sending deleted the template.
Assignee | ||
Comment 8•6 years ago
|
||
The definition of auto-save is:
A ghost comes out of a box and clicks "Save" for the user. When editing a draft, that gets saved as a draft, when editing a template, it gets saved as a template.
In both cases the previous version is overwritten. Blame it on the ghost.
I think we can keep it simple and not introduce
Ci.nsIMsgCompDeliverMode.AutoSaveAsTemplate
That fixes all problems, and after fixing bug 1498097, no template will be deleted after sending.
Assignee | ||
Updated•6 years ago
|
Attachment #9017044 -
Attachment is obsolete: true
Attachment #9017044 -
Flags: feedback?(acelists)
Comment 9•6 years ago
|
||
IIRC filters using templates are tied to a specific template, so if you delete one, you get into trouble. The user can manually delete and get these problems, but be careful with auto-delete.
Assignee | ||
Comment 10•6 years ago
|
||
Thanks for the hint. The auto-reply filter qualifies the template to use like so:
actionValue="mailbox://nobody@Local%20Folders/Templates?messageId=cd622d33-ec68-a792-1da7-791921bd9f74@jorgk.com&subject=French 2"
Editing a template maintains that ID. So as long as auto-save doesn't remove templates and stores drafts instead, we're fine.
A potential trouble is that auto-reply could be sending a template which is being edited and has been auto-saved. So the answer to this would be disabling auto-save for templates as I had previously suggested. I'll recover the patch now.
Assignee | ||
Comment 11•6 years ago
|
||
Comment on attachment 9017044 [details] [diff] [review]
1498866-no-auto-save-for-template.patch
The commit message should be changed to:
don't auto-save when editing template to conflict with auto-reply filter.
Attachment #9017044 -
Attachment is obsolete: false
Attachment #9017044 -
Flags: review?(mkmelin+mozilla)
Assignee | ||
Comment 12•6 years ago
|
||
Oops:
The commit message should be changed to:
don't auto-save when editing template to *avoid* conflict with auto-reply filter.
Comment 13•6 years ago
|
||
Comment on attachment 9017044 [details] [diff] [review]
1498866-no-auto-save-for-template.patch
Review of attachment 9017044 [details] [diff] [review]:
-----------------------------------------------------------------
We can use this as a quick fix for TB60.3, but then please file the bug for the more involved solution (autosaving template to a draft).
Attachment #9017044 -
Flags: review+
Assignee | ||
Updated•6 years ago
|
Attachment #9017048 -
Attachment is obsolete: true
Attachment #9017048 -
Flags: review?(acelists)
Assignee | ||
Updated•6 years ago
|
Attachment #9017044 -
Flags: review?(mkmelin+mozilla)
Assignee | ||
Comment 14•6 years ago
|
||
Working, but needs some tidying.
Comment 15•6 years ago
|
||
Comment on attachment 9017363 [details] [diff] [review]
1498866-proper-fix.patch - WIP
Review of attachment 9017363 [details] [diff] [review]:
-----------------------------------------------------------------
::: mailnews/compose/src/nsMsgCompose.cpp
@@ +3873,5 @@
> +
> + // Only do this if it's a drafts or templates folder.
> + uint32_t flags;
> + msgFolder->GetFlags(&flags);
> + if (!(flags & (nsMsgFolderFlags::Drafts | nsMsgFolderFlags::Templates)))
You could use isSpecialFolder instead, in case people organize their templates
Assignee | ||
Comment 16•6 years ago
|
||
I've tidied it up a bit. It mostly works apart from:
- Abandoning edit template after auto-save has happened doesn't
remove the draft
Also funny: When abandoning edit template, the prompt offers to save as draft or discard changes.
Not tested on IMAP yet.
Attachment #9017363 -
Attachment is obsolete: true
Attachment #9017455 -
Flags: feedback?(acelists)
Assignee | ||
Comment 17•6 years ago
|
||
This is the Rolls Royce solution. Auto-saved draft now also removed.
Attachment #9017455 -
Attachment is obsolete: true
Attachment #9017455 -
Flags: feedback?(acelists)
Attachment #9017457 -
Flags: feedback?(acelists)
Comment 18•6 years ago
|
||
Comment on attachment 9017457 [details] [diff] [review]
1498866-proper-fix.patch - v3
Review of attachment 9017457 [details] [diff] [review]:
-----------------------------------------------------------------
This looks and works beautifully for me.
I tested all cases I could think up on local/pop3 and on IMAP too (gmail). I couldn't find a problem.
The code changes aren't as bad, mostly just keeping the templateId too.
I like it, thanks!
::: mail/components/compose/content/MsgComposeCommands.js
@@ +4147,5 @@
> // don't delete the draft if we didn't start off editing a draft
> // and the user hasn't explicitly saved it.
> if (!gEditingDraft && gAutoSaveKickedIn)
> RemoveDraft();
> + // Remove auto-saved draftes created duting "edit template".
draft?
Attachment #9017457 -
Flags: feedback?(acelists) → feedback+
Assignee | ||
Comment 19•6 years ago
|
||
Comment on attachment 9017457 [details] [diff] [review]
1498866-proper-fix.patch - v3
I need a review to land it. I promise to fix the comment.
Attachment #9017457 -
Flags: review?(acelists)
Assignee | ||
Updated•6 years ago
|
Attachment #9017044 -
Attachment is obsolete: true
Comment 20•6 years ago
|
||
Comment on attachment 9017457 [details] [diff] [review]
1498866-proper-fix.patch - v3
Review of attachment 9017457 [details] [diff] [review]:
-----------------------------------------------------------------
::: mail/components/compose/content/MsgComposeCommands.js
@@ +4147,5 @@
> // don't delete the draft if we didn't start off editing a draft
> // and the user hasn't explicitly saved it.
> if (!gEditingDraft && gAutoSaveKickedIn)
> RemoveDraft();
> + // Remove auto-saved draftes created duting "edit template".
And "during".
Attachment #9017457 -
Flags: review?(acelists) → review+
Assignee | ||
Updated•6 years ago
|
Attachment #9017457 -
Flags: approval-comm-esr60+
Attachment #9017457 -
Flags: approval-comm-beta+
Comment 21•6 years ago
|
||
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/a312c7cf1c0e
Only delete original template when saving new template, manage auto-saved versions. r=aceman
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•6 years ago
|
Target Milestone: --- → Thunderbird 64.0
Assignee | ||
Comment 22•6 years ago
|
||
TB 63 beta 2:
https://hg.mozilla.org/releases/comm-beta/rev/df0d79b1cb646e7ebe57c348e52adc35b5ea025b
status-thunderbird63:
--- → fixed
status-thunderbird64:
--- → fixed
status-thunderbird_esr60:
--- → affected
Comment 23•6 years ago
|
||
Adjust bug summary to be clearer about what is the actual bug (Auto-Save removes template), and what we have kept/improved (manage auto-saved templates as drafts). Current summary sounds as if "auto-saving edited template as draft in drafts folder" is part of the bug, but this was ultimately not considered a bug here.
This needs more thought, because it'll be hard for users to discover that auto-saved templates end up in drafts folder. We correctly figured that we can't just overwrite the template with its auto-saved version because that might cause filters to send out half-baked templates in undefined states of editing. In an ideal world, auto-save should probably NOT act as a ghost which overwrites the original or creates undiscoverable drafts in some other folder, but offer to restore or dump the auto-saved version when an abandoned message gets re-opened (especially for the template case, due to the filter issue). The auto-saved version should be saved in some plausible location; probably in the same folder where the original lives, maybe invisible to the user (as we currently hide deleted pop messages), and maybe just indicated somehow on the existing template.
Summary: "Edit Template": template removed by Auto-save and saved as draft instead → "Edit Template": template removed by Auto-save (implemented fix: keep template and manage auto-saved drafts)
Assignee | ||
Comment 24•6 years ago
|
||
Assignee | ||
Updated•6 years ago
|
Comment 25•6 years ago
|
||
Fwiw, I had mentioned this on the original bug already (albeit unaware of the filter issue), but somehow we didn't pick that up at the time...
(In reply to Thomas D. from bug 1389062 comment #35)
> 1 Bug found (probably pre-existing):
> Auto-Save moves the template msg to drafts folder, but should just overwrite
> existing template.
Thanks Aceman and Jörg for fixing this!
You need to log in
before you can comment on or make changes to this bug.
Description
•