New-topic links with category selected navigate to that category page

This change aborts the navigation if the user was already on Discourse:

The code has changed since then and now looks like this:

The if (category) { block runs before the block that checks whether the user was already on discourse, so the navigation proceeds. This feels like the wrong order to me.