simonk
(Simon King)
Agosto 7, 2026, 2:49pm
2
Esta alteração cancela a navegação se o usuário já estivesse no Discourse:
committed 12:03AM - 27 Jun 23 UTC
Why is this change required?
The `/new-topic` route is a special route which … we use to open the
composer by loading a URL. By default, the `new-topic` route is replaced with the
`discovery.latest` route. On a fresh page load, this makes sense since
there is no template for the `new-topic` route to render. However, this
behavior does not make sense if we're transition from another route.
There is no need to replace the current route with the `discovery.latest` when all we want
is to open the composer.
What does this commit do?
This commit fixes the undesirable behaviour described above by aborting
the existing transition to the `new-topic` route if `transition.from` is
present. This indicates that we're navigating from an existing route and
we can just open the composer.
O código mudou desde então e agora está assim:
async beforeModel(transition) {
if (!this.currentUser) {
transition.send("showLogin");
return;
}
const { queryParams: params } = transition.to;
const category = await this.#loadCategoryFromTransition(params);
if (category) {
// Using URL-based transition to avoid bug with dynamic segments and refreshModel query params
// https://github.com/emberjs/ember.js/issues/16992
this.router
.replaceWith(`/c/${category.id}`)
.followRedirects()
.then(() => {
if (this.currentUser.can_create_topic) {
this.#openComposer(params, category);
}
});
O bloco if (category) { é executado antes do bloco que verifica se o usuário já estava no Discourse, portanto a navegação continua. Isso me parece estar na ordem errada.