codecombat/codecombat — pull request #1256 by rubenvereecken (2014-07-04 14:49:59+00:00)
Title: Patch fix: applyDelta now always called

This one's for Scott :)

I ended up with a fairly little patch but it was a pretty rough road. The patch view's applyDelta wasn't always called because of the messy call sequence of `onLoaded`, `render` and `afterRender`. Mix that with some conditions and it's chaos.

`applyDelta` ended up being called only when the patch is for another version of the target document. Since `render` is called by `openModalView`, some logic was skipped as well etc... The solution was to have `render` be the guardian for the `applyDelta` logic. I haven't actually tested with loading models yet, but the logic is pretty sound. Basically don't render until you've got everything you need to put on the screen.