Skip to content

Commit

Permalink
FIX: /login loop when categories is default homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
renato committed Sep 7, 2023
1 parent a6f7bb2 commit 7ff9fe6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { run } from "@ember/runloop";
import { next, run } from "@ember/runloop";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";

Expand Down Expand Up @@ -134,10 +134,9 @@ export default {
url = `/tags/intersection/${filterPref}/${additionalTags}`;
router.transitionTo(url, null, { queryParams });
} else if (transition.to?.localName === "categories") {
transition.abort();
router.transitionTo(`/categories?tag=${filterPref}`);
next(() => router.transitionTo(`/categories?tag=${filterPref}`));
} else if (transition.to?.name === "discovery.latest") {
router.transitionTo(`/tag/${filterPref}`, null, { queryParams });
router.transitionTo("tag.show", filterPref, { queryParams });
} else {
const categoryURL = categorySlug ? `s/c/${categorySlug}` : "";
url = `/tag${categoryURL}/${filterPref}`;
Expand Down
11 changes: 11 additions & 0 deletions test/javascripts/acceptance/global-filter-preference-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,16 @@ acceptance(
"it redirects to the user's global_filter_preference"
);
});

test("/login works with categories as default homepage", async function (assert) {
setDefaultHomepage("categories");
await visit("/login");

assert.equal(
currentURL(),
"/categories?tag=support",
"it redirects to the user's global_filter_preference"
);
});
}
);

0 comments on commit 7ff9fe6

Please sign in to comment.