DEV: Convert AbstractTopicRoute to native class syntax

This commit is contained in:
David Taylor 2023-08-04 14:04:14 +01:00
parent a502eb1097
commit ae95260645
1 changed files with 16 additions and 14 deletions

View File

@ -95,16 +95,16 @@ export async function findTopicList(
return list; return list;
} }
const AbstractTopicRoute = DiscourseRoute.extend({ class AbstractTopicRoute extends DiscourseRoute {
screenTrack: service(), @service screenTrack;
queryParams, queryParams = queryParams;
beforeModel() { beforeModel() {
this.controllerFor("navigation/default").set( this.controllerFor("navigation/default").set(
"filterType", "filterType",
this.routeConfig.filter.split("/")[0] this.routeConfig.filter.split("/")[0]
); );
}, }
model(data, transition) { model(data, transition) {
// attempt to stop early cause we need this to be called before .sync // attempt to stop early cause we need this to be called before .sync
@ -120,7 +120,7 @@ const AbstractTopicRoute = DiscourseRoute.extend({
findOpts, findOpts,
findExtras findExtras
); );
}, }
titleToken() { titleToken() {
if (this.routeConfig.filter === defaultHomepage()) { if (this.routeConfig.filter === defaultHomepage()) {
@ -131,7 +131,7 @@ const AbstractTopicRoute = DiscourseRoute.extend({
"filters." + this.routeConfig.filter.replace("/", ".") + ".title" "filters." + this.routeConfig.filter.replace("/", ".") + ".title"
); );
return I18n.t("filters.with_topics", { filter: filterText }); return I18n.t("filters.with_topics", { filter: filterText });
}, }
setupController(controller, model) { setupController(controller, model) {
const topicOpts = { const topicOpts = {
@ -149,7 +149,7 @@ const AbstractTopicRoute = DiscourseRoute.extend({
"canCreateTopic", "canCreateTopic",
model.get("can_create_topic") model.get("can_create_topic")
); );
}, }
renderTemplate() { renderTemplate() {
this.render("navigation/default", { outlet: "navigation-bar" }); this.render("navigation/default", { outlet: "navigation-bar" });
@ -158,17 +158,17 @@ const AbstractTopicRoute = DiscourseRoute.extend({
controller: "discovery/topics", controller: "discovery/topics",
outlet: "list-container", outlet: "list-container",
}); });
}, }
@action @action
changeSort(sortBy) { changeSort(sortBy) {
changeSort.call(this, sortBy); changeSort.call(this, sortBy);
}, }
@action @action
resetParams(skipParams = []) { resetParams(skipParams = []) {
resetParams.call(this, skipParams); resetParams.call(this, skipParams);
}, }
@action @action
willTransition() { willTransition() {
@ -178,10 +178,12 @@ const AbstractTopicRoute = DiscourseRoute.extend({
User.currentProp("user_option.redirected_to_top.reason", null); User.currentProp("user_option.redirected_to_top.reason", null);
} }
} }
return this._super(...arguments); return super.willTransition(...arguments);
}, }
}); }
export default function buildTopicRoute(filter) { export default function buildTopicRoute(filter) {
return AbstractTopicRoute.extend({ routeConfig: { filter } }); return class extends AbstractTopicRoute {
routeConfig = { filter };
};
} }