You know you're a code snob when April 9, 2014
Today I wrote a method that takes an updated object from the server and merges it with the current user's objects. These objects are in an hierarchy of client -> environment -> credentials. So I wrote a function that sees that a credential has been updated (deleted, inserted, updated), finds the client and environment that it belongs to, if it doesn't have it, it "pushes" it, otherwise if it's not a delete, it updates it, and if it's a delete it removes it. The other users can be editing clients or environments as well, so these have to work the same way.
The commit message for this change is as follows:
Update other users' data with data updated from the server. Need to clean up the compare function, in client controllers line 65 to 118
Yep, 53 lines of non-trivial code and I'm all like "That is WAY too long..." I will write a generic utility function that will do it for me. I found angular.copy to be very useful, I just need something to tell me what's changed.
I will need that function to keep track of users logging in and out as well, as it updates almost immediately for other users when someone logs out, and it uses way more code than I feel should be necessary as well.... If javascript had a universal "findIndex" method, it would be helpful, but I want to make it a 2-3 liner for these updates without writing my own "findIndex" function. More specialized...