Wedge

Public area => The Pub => Topic started by: Arantor on March 17th, 2012, 02:37 PM

Title: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 17th, 2012, 02:37 PM
Something I've noticed about drafts that I didn't quite notice before is a slightly complex chain of events that needs cleaning up.

If you type something, then preview it, it does autosave the draft, and it does actually remember that draft - so if you go from quick reply-with-draft through to preview, it won't create a second draft (as it shouldn't), but you won't be able to delete that draft there and then, you'll have to wait until the post is edited and resaved automatically. (Confirmed here just now, I was able to start a post, let it autosave, preview, then noted the behaviour)

I suspect something similar occurs to PMs, too.

I still need to fix the case of editing a draft when the board no longer exists that the draft originally came from.[1]


Also: IMO, the tabindex structure on posting is a touch off, it needs to go from subject to body, not via the selectboxes. I don't think it should take 4 tabs to get from subject to body.
 1. If you have a draft for a reply, but the topic no longer exists, that's fine, it will just take you to editing as if you were creating a new topic. But if the board no longer exists, it gets very upset and dumps you at the no_board error.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 17th, 2012, 04:50 PM
Hmm, there are plenty of little issues with it, but it's okay. Drafts, and the way they're implemented (also in PMs!), are one of the selling points of Wedge.
One thing I noticed, and would like to suggest, is that if Remove Draft is clicked, either reset the timeout counter, or just disable it, because it's unlikely the author really plans to post the message (may be testing something). At some point I clicked Removed Draft, and the button showed up again two seconds later... ;)

Ah, bugger, button icons are broken in IE9... :-/
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 17th, 2012, 04:53 PM
Yeah, that's doable I guess, we can do that. (I'd rather disable it than reset the counter, though.) And yes, it's just happened to me here in testing :/
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 17th, 2012, 06:11 PM
OK, so I've fixed the remove-draft-but-still-saves bug locally. Trying to figure out how best to approach the other issue I mentioned though.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 17th, 2012, 08:01 PM
Thanks for the fix :)
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 18th, 2012, 01:04 PM
So, gotta fix that PM bug.

Also, I'm thinking I should tweak the quick reply version, I'm not sure I like the way it runs the entire set of buttons into a single line (whereas the full reply screen pushes the last saved/remove button to the next line)
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 18th, 2012, 08:25 PM
The PM bug should be fixed in r1482.

Any thoughts about the quick reply buttons splitting to a second line like they do in full reply?
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 01:02 PM
Possible bug...? If yes, it's minor.

Yesterday, I tapped Quick Reply (it's collapsed by default) to answer a post.
Right after it opened the (empty) QR box, the first draft was saved.

This could mean two bugs: drafts are still saved on empty contents, and the draft timer is started even if the QR box is closed.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 22nd, 2012, 01:05 PM
Let me explain how it works under the hood, that might explain the behaviour you're seeing.

There is a timer started straight away, x second intervals (where the x is the admin setting, default 30). Nothing should happen, however, unless a keydown event is sent to the editor object, which sets a flag in the drafts object to indicate that next time the timer hits its interval, to make a save. The save is sent off, on return it clears that flag.

Theoretically, then, it should never be saving until there is something to save... with a variable amount of time between you typing and the first save (0-x seconds) but ~x seconds thereafter assuming constant typing.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 02:15 PM
all I can say is that it happened again right now. On this post. Except the message was there already when I opened it.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 02:17 PM
Tried again. Opened box. Waited. Saved itself. Meh.
So there really is an issue in iOS.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 02:18 PM
Checked my drafts. I have 1389 drafts since March 16. No typo.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 22nd, 2012, 02:20 PM
The hell?

Still, there's a remove all button now...
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 02:30 PM
Yep, but there's no point in using it, we need to fix that...

- Make sure that drafts don't get saved if the same text is already in the database,
- Ensure they really don't get saved if no activity is found...
- Ensure they don't get saved *if the post is empty* (even if there's activity like keydown, Wedge still saves an empty draft for EVERY topic I'm simply reading with my iPod...!)
- Make sure that iOS generally won't screw up with drafts.
- Ensure all drafts are removed for a specific post once it's sent.

Looking at my latest drafts:

- this(http://wedge.org/pub/7221/improvement-to-drafts-and-posting-actually-i-need-to-do/msg275981/#msg275981) is found as a draft, completely the same post. Not even a partial one... Same for the Werner Herzog post.

- the current post is updated in real time, with no extra drafts being created for it, so that one is okay.

- an empty draft for a New Revs post (I never post there from my iPod), but no empty drafts for my other recent Opera posts.

- that empty draft says, "This draft is a reply to a topic that is currently locked by a moderator. Editing this draft will attempt to create a new topic." --> yeah, but I'm the admin... I can post it there if I want! Does the feature at least check against that...?

- about 1350 drafts are the same post -- a Logo Madness draft that is just a quote of another post, possibly a tab I opened somewhere with a plan to post a reply, and then 12 hours later I found the tab and just closed it. It saved a new copy of the draft every single time... :-/
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 04:32 PM
Okay, I've made a few changes to the draft code... Hopefully it will help, if only a bit.

- needsUpdate is set to false right after it's tested against. This is to ensure that drafts don't get saved multiple times if for some reason the function is executed again before the server has answered. (e.g. server is temporarily down...?)
- if 'message' is empty, return without doing anything. I don't think there's any good reason to save an empty draft. Really.

Will commit soon. Pete, this is your code, so feel free to revert at any time without explanations. I'm not even sure I'm doing it correctly :P
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 22nd, 2012, 04:43 PM
Commit it, deploy it, if it works, great, if not, we'll fix it :)
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 04:47 PM
All I can say is, I kept a textarea open for a while and it didn't save anything. But maybe it was already the case before :)
Then again, I haven't had a 'dirty' draft for over 2 hours -- i.e. back when I last used my iPod to navigate here.
I'm off to take a half-hour break. I'll try to see if it keeps doing it on the iPod!

PS: lol, it's broken I think... I'm not seeing any draft saved, even after typing for a minute or so!
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 06:59 PM
Fixed some of the bugs. Maybe all? Lol I dunno.
Works in Opera AND iOS when it comes to empty posts. No longer triggers anything if empty. If I type something, it triggers.
Doesn't seem to trigger on iOS when typing text.
Ah well.
Posted: March 22nd, 2012, 06:55 PM

And, working!! :)
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 22nd, 2012, 07:04 PM
Sounds good to me, though I'd not actually had any problems on iOS with my iPad, curiously enough. I'm starting to wonder if iPad 1 / iOS 5.0 does things a bit differently to everyone else :-/
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 07:43 PM
Dunno. That's a possibility.
I'd be most interested in knowing if anyone else's getting the problem I have on my 4.2 -- unresponsive keyboard when I tap a textarea or input box. Because as of now, I have no idea how to fix that...
Posted: March 22nd, 2012, 07:27 PM

Okay, I'm done with my commit -- won't spend more time today on drafts and blog posts, so if you want to look into the 'recent posts first' bugs, please do it... :) (That's valid for anyone ;))

I also didn't touch the menu icon overlay code -- just forgot about it. And I'm still a bit wary of touching that area again... (Just like I was wary about touching Class-CSS.php this morning, as it's grown to be so complex :P)
So, if anyone could remind me to do it later...
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Pandos on March 22nd, 2012, 08:16 PM
Sorry, but for me it doesn't work. Even if i "save it as draft".
The only message i get:


You have no draft messages saved at this time
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 09:45 PM
Can anyone confirm whether it works or not for them?
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 09:46 PM
Btw my New Revs post draft wasn't deleted.
Maybe because it is a locked topic?
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 22nd, 2012, 09:57 PM
Hmm, it seems to be working for me just fine?

If you happen to post between the first AJAX submission and it coming back, it won't be deleted because it won't have the id to delete. What we could do, potentially, is block posting while sending off the AJAX request, but if there's a problem it's still going to disappear into the aether like that.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on March 22nd, 2012, 10:57 PM
Imagine that: clicking the submit button right when the autosave triggers.
It's only a problem for a week at the most, though.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on March 22nd, 2012, 11:05 PM
Sure, and it's not like the odds are that high of doing it either, maybe just bad luck :/

I'd note that disabling the save button is exactly what WP does when autosaving drafts but of course that's a slightly different context in which to do it.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on May 26th, 2012, 10:03 AM
Suggesting an improvement for drafts...

I submitted a post and got a "There was a reply..." message and the full post again.
I then got a browser crash while opening Dragonfly. (Thank you, Opera 12...)
I restarted, and my draft only had half of the post.

So my suggestion would be to save the draft automatically when you hit Preview or you get an error message and the full post page.
What do you think...?
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on May 26th, 2012, 02:05 PM
Seems meaningful enough, shouldn't be a big deal - in theory there will already be a draft id to work with at that point. The trick is to seamlessly fold it into the different routes of saving drafts.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on May 29th, 2012, 05:26 PM
(And that's where my expertise stops dead... :P)
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on May 29th, 2012, 05:34 PM
You know what, though? I wrote the damn thing and I only barely remember how I did it :P
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on June 4th, 2012, 06:18 PM
Also on an unrelated note, while discussing something over PM, the idea came to me that we could track the number of drafts that are in use for a given member, and display that as a notice variable for the PMs and posts, so that you'd know you had drafts around.

The person I was talking to was not that enthusiastic, hahahaa, but I thought I'd suggest it generally in case others like the idea.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on June 4th, 2012, 06:36 PM
For it to work, we'd need to have a flawless draft system ie no ghost drafts as happen from time to time.
I'd rather see Wedge fill in empty textareas with drafts if they're available. Although that would conflict with browser plugins that do just that.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on June 4th, 2012, 06:39 PM
I haven't seen any ghost drafts in a while and I've been using it fairly heavily ;)

Not so much posting drafts, maybe, but really for PM drafts I think it'd be beneficial.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: godboko71 on June 4th, 2012, 09:48 PM
I like the idea for PM's not sure how useful it would be for Normal Posts.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on June 4th, 2012, 11:31 PM
Went into my general draft section...

I have several drafts <= June 1st, but let's see for today:

1
Off-topic / Re: MySQL query optimization
« Today at 11:14 PM »
 EXPLAIN is one of those things that make possibly the only thing that is more confusing to me than regexps... Actually the

2
Off-topic / Re: Old layout vs new layout?
« Today at 09:32 PM »
 Looking good!

Footer needs extra top padding!

---> The second one was made on my iPod. The first one on Opera Desktop. In both cases, I posted these messages without any further trouble... So there still is a small issue with ghost drafts.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on June 4th, 2012, 11:41 PM
What we have here is a race condition, yay.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on June 4th, 2012, 11:43 PM
Another...?!!
Or maybe the infamous issue with drafts being saved after clicking the submit button?

Okay time for bed really... I hope you find some time to look into the membergroup caching stuff! okthxbye
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on June 5th, 2012, 12:23 AM
No, it's the same race condition.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on June 5th, 2012, 07:41 AM
Eh? Its not insert ignore material..?
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on June 5th, 2012, 12:48 PM
Nope, because you have two separate events going on, and sometimes one of those happens to occur later than the other.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on June 5th, 2012, 01:17 PM
Draft & submit?

How about disabling drafts as soon as the submit button is hit?
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on June 5th, 2012, 01:21 PM
Well, we can stop the submission of further drafts, sure, but we can still have a draft being sent just around the same time as post is sent, and still have a race condition there anyway.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on June 5th, 2012, 02:06 PM
Chances that this will happen are VERY slim, while a draft being submitted after hitting submit are much higher, because it can take a few seconds for a post to be sent and redirect to the next page -- and during these few seconds, the draft system might very well decide to save the post on its side... i.e. while the post is being submitted, i.e. most likely AFTER the draft was supposedly removed from the database.

(Why don't you comment on my request for membergroup caching...? Out of ideas?)
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on June 5th, 2012, 02:07 PM
And another draft for me today -- in the Mobile version topic. And once again, it's an incomplete post written on my iPod, meaning that there is definitely a problem with the draft system, even without race conditions taken into account.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on June 5th, 2012, 02:24 PM
OK, so it does need some work then, I'll look at it a bit later on.
Quote
(Why don't you comment on my request for membergroup caching...? Out of ideas?)
Because I'm tired and feel like crap and can't really process all the consequences of it right now.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Nao on June 16th, 2012, 07:59 PM
Quote from Arantor on June 5th, 2012, 02:24 PM
Because I'm tired and feel like crap and can't really process all the consequences of it right now.
Feeling better now? :P
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on June 16th, 2012, 08:23 PM
I wish.

I've spent a couple of days trying to unwind, playing some games, I have even briefly attempted to write some code but ended up spending an evening railing at a stupid problem caused by a stupid library having a stupid undocumented hidden internal limit that when exceeded causes a stupid error that seemingly has nothing to do with the call that is made.

This is a lot of what frustrates me about computer programming. It's all deterministic which means that I should be able to make a change and understand the consequences of that change in the places it affects. Except increasingly I'm finding that changing one thing breaks things that seemed to be unrelated, and it's frustrating me that I can't keep up with it. I didn't get into programming to play whack-a-mole.

I would also note that recently I've spent some time re-evaluating why I got into programming, and the otherwise simply joy of making things isn't there so much these days; I remember when I could make something in an afternoon and it would work. These days I can't build anything in under two days and spend even longer fighting with it.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Johnny54 on June 16th, 2012, 10:59 PM
The development in computers go faster and faster. Just trying to keep up with all new things in programming languages,, the way things are programmed, new stuff in operating systems, databases etc takes a lot of time.
Further more are programs more complicated as they used to be, Simply because  people expect more fancy stuff, possibilities, speed etc.
All this makes programming timeconsuming and challenging but can also lead to frustration.

I think that excepting that your human and that you just can't shake code out of your sleeve at a great rate would give you some peace of mind.
I mean well so I hope your not offended by this post.
Title: Re: Improvement to drafts (and posting, actually) I need to do
Post by: Arantor on June 16th, 2012, 11:05 PM
I'm not offended at all :)

On the contrary, I think it's great that people are beginning to understand that - Nao and I sometimes make coding look easy but it really isn't, and I do think people forget just how much we've done in order to be where we are, e.g. how much time we've spent learning the language and then the specific implementation.