The dating game tales from the trenches

02-Nov-2015 00:10 by 5 Comments

The dating game tales from the trenches - Adult Chat Rooms

the wrong way around, but before realising this I also noticed that my original source object was also getting updated. After checking the docs I realised both j Query and Underscore/Lodash refer to the first object passed to the function as the destination object.So while the function also (curiously) returns this destination object, it is in fact mutated in-place as part of the extend operation.

The bug reported was that these links only work the they are clicked. I spent more time than I'd like to admit reading and stepping through the code to work out what was going on, and just found myself going round in circles. Well, when setting the value of the datepicker via my helper links if the date being set is different to the current month/year of the datepicker then this event gets fired. Ok, so I guess it's expected and probably useful that this event fires both when the user changes the month/year via the control and also when the date is changed via the API.Recently I had added a hook for the event on Change Month Year so that when the user changed the month or year from the open datepicker it would default to the first of that month (as this is what my users usually want to do, and the out-of-the-box behaviour is to do nothing). So here's my first fix, checking if the datepicker is visible... I can see that my check as to wether or not the datepicker is visible is working, and am confident it's required...but the date is still being set incorrectly and needs two clicks.After more debugging and code reading it turns out the bug comes from my usage of the get Date API method.This method does not just return the date from the datepicker, but in doing so mutates the internal state of the control. I'm only trying to set the date to the 1st if the datepicker is open, but also only accessing the current date of the control when this is the case.This means that when the handler fires after the date has been set programatically it won't step in and bugger things up.

My take away from this is a reminder as to the complications and dangers of managing state, and how immutability makes things safer and less unexpected.

I took a look to see if I could contribute this note to the official docs but there was no obvious way to do so.

I'm aware of Javascript scope rules and the fact my picker and current vars are actually visible to the entire function, but I prefer to ignore particular gotcha in favour of readability.

After writing this I realised that my second gotcha (while valid) is actually calling the get Date API unnecessarily. Today I ran into an interesting (though afterwards 'doh!

of course...') problem involving a slow My SQL query that should have been a hell of a lot quicker.

The application I work on supports users in many timezones, so when it comes to query time we always need to adjust system recorded times (which are always UTC) to allow for the users current timezone. I mentioned in my last post that the main application I work on has just undergone a redesign.