ElkArte Community

Title: Too many drafts
Post by: emanuele on July 07, 2014, 12:54:58 pm
I think this can be considered a bug, at the moment, it seems that in certain conditions, when you post a new topic, or a reply, or something, the draft of that message is not deleted if auto-saving of drafts is on.

I'm not sure how to reproduce it actually... :-\
Title: Re: Too many drafts
Post by: Spuds on July 07, 2014, 03:28:21 pm
Yup, drafts can be like that  :P   I'll troll the code again and see if something jumps out and goes boo !

Quick question, on QR, do you use the full editor or just the text box?
Title: Re: Too many drafts
Post by: Jorin on July 07, 2014, 04:32:36 pm
I experienced this too.  :-[
Title: Re: Too many drafts
Post by: emanuele on July 07, 2014, 06:41:12 pm
Quote from: Spuds – Quick question, on QR, do you use the full editor or just the text box?
Textbox.
You know I'm old style! :P
Title: Re: Too many drafts
Post by: Spuds on July 07, 2014, 07:36:48 pm
Well I found one way to do this ...

If you use QR and enter a response (short and fast) and hit post before the first autosave, ever fires, then the id_draft is not updated in the form.  However pressing "post" fires the autosave since the editor looses focus so the draft is saved the form submitted with no draft_id yet so it saves the post and the draft.
Title: Re: Too many drafts
Post by: emanuele on July 08, 2014, 02:52:55 am
Race, race, race! YAY! :P

ETA: oh... and now that I think about it, that's not unusual for me, because I type the answer, hit "tab" and "enter", that means start autosave, start post. I did it without even realizing with that very post... lol
Title: Re: Too many drafts
Post by: Spuds on July 08, 2014, 06:54:46 am
Yup two conditions, the before first draft save event ... that's almost guaranteed to save and not delete.  Then we have the race condition where you have an autodraft saved and hit post, now its a race where the post event wants to delete the draft and the autosave wants to save a new one, which wins :P

Trying some different things to tie in to the form submit.
Title: Re: Too many drafts
Post by: emanuele on July 08, 2014, 07:49:03 am
Worst case: a scheduled task that checks if you posted anything with the same text... ugly?
Title: Re: Too many drafts
Post by: Spuds on July 08, 2014, 09:35:05 am
First pass at a fix for what I know can be a problem

https://github.com/elkarte/Elkarte/pull/1716