FIX: Do a transition to update 'solved' queryparam (#184)
A more involved transition / redirect was happening which sometimes made Ember think it was an incomplete transition and threw an error.
This commit is contained in:
parent
5e87180ed7
commit
ec9258d2ee
|
@ -1,5 +1,4 @@
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import DiscourseUrl from "discourse/lib/url";
|
|
||||||
import { getOwner } from "discourse-common/lib/get-owner";
|
import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -42,23 +41,11 @@ export default {
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
changeStatus(newStatus) {
|
changeStatus(newStatus) {
|
||||||
let location = window.location;
|
const router = getOwner(this).lookup("router:main");
|
||||||
let queryStrings = location.search;
|
|
||||||
let params = queryStrings.startsWith("?")
|
|
||||||
? queryStrings.substr(1).split("&")
|
|
||||||
: [];
|
|
||||||
|
|
||||||
params = params.filter((param) => !param.startsWith("solved="));
|
|
||||||
|
|
||||||
if (newStatus && newStatus !== "all") {
|
if (newStatus && newStatus !== "all") {
|
||||||
newStatus = newStatus === "solved" ? "yes" : "no";
|
newStatus = newStatus === "solved" ? "yes" : "no";
|
||||||
params.push(`solved=${newStatus}`);
|
|
||||||
}
|
}
|
||||||
|
router.transitionTo({ queryParams: { solved: newStatus } });
|
||||||
queryStrings = params.length > 0 ? `?${params.join("&")}` : "";
|
|
||||||
DiscourseUrl.routeTo(
|
|
||||||
`${location.pathname}${queryStrings}${location.hash}`
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue