Currently when a user clicks on an edit notification, we use
notify the topics controller that it should open up the history modal for the
edited post and the appEvents callback opens up the history modal in the next
Ember runloop (by scheduling an
There are 2 problems with this implementation:
- the callbacks are fired/executed too early and if the post has never been
loaded from the server (i.e. not in cache), we will not get a modal history
because the method that shows the modal
returns if it can’t find the post:
- when clicking an edit notification from a non-topic page, you’re redirected
to the topic page that contains the edited post and you’ll see the history
modal briefly and it’ll be closed immediately. The reason for this is because
we attempt to show the history modal before the route transition finishes
completely, and we have cleanup code in
initializers/page-tracking.jsthat’s called after every transition and it does several things one of which is closing any open modals.
The fix in this PR defers showing the history modal until posts are loaded (whether fresh or cached). It works by storing some bits of information (topic id, post number, revision number) whenever the user clicks on an edit notification, and when the user is redirected to the topic (or scrolled to the edited post if they’re already in the topic), the post stream model checks if we have stored information of an edit notification and requests the history modal to be shown by the topics controller.