DEV: migrate (almost all) routes from `actions:` to `@action` syntax (#14722)
This should be safe, all these places are pretty straightforward. I've run into one problem when changing this, though. That problem was fixed in https://github.com/discourse/discourse/pull/14624
This commit is contained in:
parent
88f9bb3dc9
commit
284ab8cdf7
|
@ -1,6 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "I18n";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
model() {
|
||||
|
@ -36,10 +37,9 @@ export default DiscourseRoute.extend({
|
|||
return I18n.t("about.simple_title");
|
||||
},
|
||||
|
||||
actions: {
|
||||
didTransition() {
|
||||
this.controllerFor("application").set("showFooter", true);
|
||||
return true;
|
||||
},
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("application").set("showFooter", true);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { emojiUnescape } from "discourse/lib/text";
|
||||
import { escapeExpression } from "discourse/lib/utilities";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default function (filter) {
|
||||
return DiscourseRoute.extend({
|
||||
actions: {
|
||||
didTransition() {
|
||||
this.controllerFor("user-posts")._showFooter();
|
||||
return true;
|
||||
},
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("user-posts")._showFooter();
|
||||
return true;
|
||||
},
|
||||
|
||||
model() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import CategoryList from "discourse/models/category-list";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import EmberObject from "@ember/object";
|
||||
import EmberObject, { action } from "@ember/object";
|
||||
import I18n from "I18n";
|
||||
import OpenComposer from "discourse/mixins/open-composer";
|
||||
import PreloadStore from "discourse/lib/preload-store";
|
||||
|
@ -130,31 +130,34 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, {
|
|||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
triggerRefresh() {
|
||||
this.refresh();
|
||||
},
|
||||
@action
|
||||
triggerRefresh() {
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
createCategory() {
|
||||
this.transitionTo("newCategory");
|
||||
},
|
||||
@action
|
||||
createCategory() {
|
||||
this.transitionTo("newCategory");
|
||||
},
|
||||
|
||||
reorderCategories() {
|
||||
showModal("reorderCategories");
|
||||
},
|
||||
@action
|
||||
reorderCategories() {
|
||||
showModal("reorderCategories");
|
||||
},
|
||||
|
||||
createTopic() {
|
||||
if (this.get("currentUser.has_topic_draft")) {
|
||||
this.openTopicDraft();
|
||||
} else {
|
||||
this.openComposer(this.controllerFor("discovery/categories"));
|
||||
}
|
||||
},
|
||||
@action
|
||||
createTopic() {
|
||||
if (this.get("currentUser.has_topic_draft")) {
|
||||
this.openTopicDraft();
|
||||
} else {
|
||||
this.openComposer(this.controllerFor("discovery/categories"));
|
||||
}
|
||||
},
|
||||
|
||||
didTransition() {
|
||||
next(() => this.controllerFor("application").set("showFooter", true));
|
||||
return true;
|
||||
},
|
||||
@action
|
||||
didTransition() {
|
||||
next(() => this.controllerFor("application").set("showFooter", true));
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import User from "discourse/models/user";
|
|||
import { scrollTop } from "discourse/mixins/scroll-top";
|
||||
import { setTopicList } from "discourse/lib/topic-list-tracker";
|
||||
import Site from "discourse/models/site";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend(OpenComposer, {
|
||||
queryParams: {
|
||||
|
@ -44,52 +45,57 @@ export default DiscourseRoute.extend(OpenComposer, {
|
|||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
loading() {
|
||||
this.controllerFor("discovery").loadingBegan();
|
||||
@action
|
||||
loading() {
|
||||
this.controllerFor("discovery").loadingBegan();
|
||||
|
||||
// We don't want loading to bubble
|
||||
return true;
|
||||
},
|
||||
// We don't want loading to bubble
|
||||
return true;
|
||||
},
|
||||
|
||||
loadingComplete() {
|
||||
this.controllerFor("discovery").loadingComplete();
|
||||
if (!this.session.get("topicListScrollPosition")) {
|
||||
scrollTop();
|
||||
}
|
||||
},
|
||||
@action
|
||||
loadingComplete() {
|
||||
this.controllerFor("discovery").loadingComplete();
|
||||
if (!this.session.get("topicListScrollPosition")) {
|
||||
scrollTop();
|
||||
}
|
||||
},
|
||||
|
||||
didTransition() {
|
||||
this.send("loadingComplete");
|
||||
@action
|
||||
didTransition() {
|
||||
this.send("loadingComplete");
|
||||
|
||||
const model = this.controllerFor("discovery/topics").get("model");
|
||||
setTopicList(model);
|
||||
},
|
||||
const model = this.controllerFor("discovery/topics").get("model");
|
||||
setTopicList(model);
|
||||
},
|
||||
|
||||
// clear a pinned topic
|
||||
clearPin(topic) {
|
||||
topic.clearPin();
|
||||
},
|
||||
// clear a pinned topic
|
||||
@action
|
||||
clearPin(topic) {
|
||||
topic.clearPin();
|
||||
},
|
||||
|
||||
createTopic() {
|
||||
if (this.get("currentUser.has_topic_draft")) {
|
||||
this.openTopicDraft();
|
||||
} else {
|
||||
this.openComposer(this.controllerFor("discovery/topics"));
|
||||
}
|
||||
},
|
||||
@action
|
||||
createTopic() {
|
||||
if (this.get("currentUser.has_topic_draft")) {
|
||||
this.openTopicDraft();
|
||||
} else {
|
||||
this.openComposer(this.controllerFor("discovery/topics"));
|
||||
}
|
||||
},
|
||||
|
||||
dismissReadTopics(dismissTopics) {
|
||||
const operationType = dismissTopics ? "topics" : "posts";
|
||||
this.send("dismissRead", operationType);
|
||||
},
|
||||
@action
|
||||
dismissReadTopics(dismissTopics) {
|
||||
const operationType = dismissTopics ? "topics" : "posts";
|
||||
this.send("dismissRead", operationType);
|
||||
},
|
||||
|
||||
dismissRead(operationType) {
|
||||
const controller = this.controllerFor("discovery/topics");
|
||||
controller.send("dismissRead", operationType, {
|
||||
categoryId: controller.get("category.id"),
|
||||
includeSubcategories: !controller.noSubcategories,
|
||||
});
|
||||
},
|
||||
@action
|
||||
dismissRead(operationType) {
|
||||
const controller = this.controllerFor("discovery/topics");
|
||||
controller.send("dismissRead", operationType, {
|
||||
categoryId: controller.get("category.id"),
|
||||
includeSubcategories: !controller.noSubcategories,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
serialize() {
|
||||
return "";
|
||||
},
|
||||
|
||||
actions: {
|
||||
didTransition() {
|
||||
this.controllerFor("application").set("showFooter", true);
|
||||
return true;
|
||||
},
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("application").set("showFooter", true);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ import I18n from "I18n";
|
|||
import PreloadStore from "discourse/lib/preload-store";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { escapeExpression } from "discourse/lib/utilities";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
queryParams: {
|
||||
|
@ -64,10 +65,9 @@ export default DiscourseRoute.extend({
|
|||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
didTransition() {
|
||||
this.controllerFor("full-page-search")._showFooter();
|
||||
return true;
|
||||
},
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("full-page-search")._showFooter();
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "I18n";
|
||||
import { get } from "@ember/object";
|
||||
import { action, get } from "@ember/object";
|
||||
|
||||
export function buildGroupPage(type) {
|
||||
return DiscourseRoute.extend({
|
||||
|
@ -29,10 +29,9 @@ export function buildGroupPage(type) {
|
|||
this.render("group-activity-posts");
|
||||
},
|
||||
|
||||
actions: {
|
||||
didTransition() {
|
||||
return true;
|
||||
},
|
||||
@action
|
||||
didTransition() {
|
||||
return true;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "I18n";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
titleToken() {
|
||||
|
@ -14,9 +15,8 @@ export default DiscourseRoute.extend({
|
|||
this.controllerFor("group-manage-logs").setProperties({ model });
|
||||
},
|
||||
|
||||
actions: {
|
||||
willTransition() {
|
||||
this.controllerFor("group-manage-logs").reset();
|
||||
},
|
||||
@action
|
||||
willTransition() {
|
||||
this.controllerFor("group-manage-logs").reset();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import RestrictedUserRoute from "discourse/routes/restricted-user";
|
||||
import UserBadge from "discourse/models/user-badge";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default RestrictedUserRoute.extend({
|
||||
showFooter: true,
|
||||
|
@ -33,9 +34,8 @@ export default RestrictedUserRoute.extend({
|
|||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
showAvatarSelector(user) {
|
||||
showModal("avatar-selector").setProperties({ user });
|
||||
},
|
||||
@action
|
||||
showAvatarSelector(user) {
|
||||
showModal("avatar-selector").setProperties({ user });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import RestrictedUserRoute from "discourse/routes/restricted-user";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default RestrictedUserRoute.extend({
|
||||
showFooter: true,
|
||||
|
@ -34,27 +35,26 @@ export default RestrictedUserRoute.extend({
|
|||
.finally(() => controller.set("loading", false));
|
||||
},
|
||||
|
||||
actions: {
|
||||
willTransition(transition) {
|
||||
this._super(...arguments);
|
||||
@action
|
||||
willTransition(transition) {
|
||||
this._super(...arguments);
|
||||
|
||||
const controller = this.controllerFor("preferences/second-factor");
|
||||
const user = controller.get("currentUser");
|
||||
const settings = controller.get("siteSettings");
|
||||
const controller = this.controllerFor("preferences/second-factor");
|
||||
const user = controller.get("currentUser");
|
||||
const settings = controller.get("siteSettings");
|
||||
|
||||
if (
|
||||
transition.targetName === "preferences.second-factor" ||
|
||||
!user ||
|
||||
user.is_anonymous ||
|
||||
user.second_factor_enabled ||
|
||||
(settings.enforce_second_factor === "staff" && !user.staff) ||
|
||||
settings.enforce_second_factor === "no"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
transition.targetName === "preferences.second-factor" ||
|
||||
!user ||
|
||||
user.is_anonymous ||
|
||||
user.second_factor_enabled ||
|
||||
(settings.enforce_second_factor === "staff" && !user.staff) ||
|
||||
settings.enforce_second_factor === "no"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
transition.abort();
|
||||
return false;
|
||||
},
|
||||
transition.abort();
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { isPresent } from "@ember/utils";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
model(params) {
|
||||
|
@ -74,9 +75,8 @@ export default DiscourseRoute.extend({
|
|||
this.messageBus.unsubscribe("/reviewable_claimed");
|
||||
},
|
||||
|
||||
actions: {
|
||||
refreshRoute() {
|
||||
this.refresh();
|
||||
},
|
||||
@action
|
||||
refreshRoute() {
|
||||
this.refresh();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ import Draft from "discourse/models/draft";
|
|||
import { isEmpty } from "@ember/utils";
|
||||
import { isTesting } from "discourse-common/config/environment";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
// This route is used for retrieving a topic based on params
|
||||
export default DiscourseRoute.extend({
|
||||
|
@ -114,16 +115,12 @@ export default DiscourseRoute.extend({
|
|||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
willTransition() {
|
||||
this.controllerFor("topic").set(
|
||||
"previousURL",
|
||||
document.location.pathname
|
||||
);
|
||||
@action
|
||||
willTransition() {
|
||||
this.controllerFor("topic").set("previousURL", document.location.pathname);
|
||||
|
||||
// NOTE: omitting this return can break the back button when transitioning quickly between
|
||||
// topics and the latest page.
|
||||
return true;
|
||||
},
|
||||
// NOTE: omitting this return can break the back button when transitioning quickly between
|
||||
// topics and the latest page.
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ import { cancel, later, schedule } from "@ember/runloop";
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import { ID_CONSTRAINT } from "discourse/models/topic";
|
||||
import { get } from "@ember/object";
|
||||
import { action, get } from "@ember/object";
|
||||
import { isEmpty } from "@ember/utils";
|
||||
import { inject as service } from "@ember/service";
|
||||
import { setTopicId } from "discourse/lib/topic-list-tracker";
|
||||
|
@ -60,185 +60,197 @@ const TopicRoute = DiscourseRoute.extend({
|
|||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
showInvite() {
|
||||
let invitePanelTitle;
|
||||
@action
|
||||
showInvite() {
|
||||
let invitePanelTitle;
|
||||
|
||||
if (this.isPM) {
|
||||
invitePanelTitle = "topic.invite_private.title";
|
||||
} else if (this.invitingToTopic) {
|
||||
invitePanelTitle = "topic.invite_reply.title";
|
||||
} else {
|
||||
invitePanelTitle = "user.invited.create";
|
||||
}
|
||||
if (this.isPM) {
|
||||
invitePanelTitle = "topic.invite_private.title";
|
||||
} else if (this.invitingToTopic) {
|
||||
invitePanelTitle = "topic.invite_reply.title";
|
||||
} else {
|
||||
invitePanelTitle = "user.invited.create";
|
||||
}
|
||||
|
||||
showModal("share-and-invite", {
|
||||
modalClass: "share-and-invite",
|
||||
panels: [
|
||||
{
|
||||
id: "invite",
|
||||
title: invitePanelTitle,
|
||||
model: {
|
||||
inviteModel: this.modelFor("topic"),
|
||||
},
|
||||
showModal("share-and-invite", {
|
||||
modalClass: "share-and-invite",
|
||||
panels: [
|
||||
{
|
||||
id: "invite",
|
||||
title: invitePanelTitle,
|
||||
model: {
|
||||
inviteModel: this.modelFor("topic"),
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
|
||||
showFlags(model) {
|
||||
let controller = showModal("flag", { model });
|
||||
controller.setProperties({ flagTopic: false });
|
||||
},
|
||||
@action
|
||||
showFlags(model) {
|
||||
let controller = showModal("flag", { model });
|
||||
controller.setProperties({ flagTopic: false });
|
||||
},
|
||||
|
||||
showFlagTopic() {
|
||||
const model = this.modelFor("topic");
|
||||
let controller = showModal("flag", { model });
|
||||
controller.setProperties({ flagTopic: true });
|
||||
},
|
||||
@action
|
||||
showFlagTopic() {
|
||||
const model = this.modelFor("topic");
|
||||
let controller = showModal("flag", { model });
|
||||
controller.setProperties({ flagTopic: true });
|
||||
},
|
||||
|
||||
showPagePublish() {
|
||||
const model = this.modelFor("topic");
|
||||
showModal("publish-page", {
|
||||
model,
|
||||
title: "topic.publish_page.title",
|
||||
});
|
||||
},
|
||||
@action
|
||||
showPagePublish() {
|
||||
const model = this.modelFor("topic");
|
||||
showModal("publish-page", {
|
||||
model,
|
||||
title: "topic.publish_page.title",
|
||||
});
|
||||
},
|
||||
|
||||
showTopicTimerModal() {
|
||||
const model = this.modelFor("topic");
|
||||
@action
|
||||
showTopicTimerModal() {
|
||||
const model = this.modelFor("topic");
|
||||
|
||||
const topicTimer = model.get("topic_timer");
|
||||
if (!topicTimer) {
|
||||
model.set("topic_timer", {});
|
||||
const topicTimer = model.get("topic_timer");
|
||||
if (!topicTimer) {
|
||||
model.set("topic_timer", {});
|
||||
}
|
||||
|
||||
showModal("edit-topic-timer", { model });
|
||||
this.controllerFor("modal").set("modalClass", "edit-topic-timer-modal");
|
||||
},
|
||||
|
||||
@action
|
||||
showTopicSlowModeUpdate() {
|
||||
const model = this.modelFor("topic");
|
||||
|
||||
showModal("edit-slow-mode", { model });
|
||||
},
|
||||
|
||||
@action
|
||||
showChangeTimestamp() {
|
||||
showModal("change-timestamp", {
|
||||
model: this.modelFor("topic"),
|
||||
title: "topic.change_timestamp.title",
|
||||
});
|
||||
},
|
||||
|
||||
@action
|
||||
showFeatureTopic() {
|
||||
showModal("featureTopic", {
|
||||
model: this.modelFor("topic"),
|
||||
title: "topic.feature_topic.title",
|
||||
});
|
||||
this.controllerFor("modal").set("modalClass", "feature-topic-modal");
|
||||
this.controllerFor("feature_topic").reset();
|
||||
},
|
||||
|
||||
@action
|
||||
showHistory(model, revision) {
|
||||
let historyController = showModal("history", {
|
||||
model,
|
||||
modalClass: "history-modal",
|
||||
});
|
||||
historyController.refresh(model.get("id"), revision || "latest");
|
||||
historyController.set("post", model);
|
||||
historyController.set("topicController", this.controllerFor("topic"));
|
||||
},
|
||||
|
||||
@action
|
||||
showGrantBadgeModal() {
|
||||
showModal("grant-badge", {
|
||||
model: this.modelFor("topic"),
|
||||
title: "admin.badges.grant_badge",
|
||||
});
|
||||
},
|
||||
|
||||
@action
|
||||
showRawEmail(model) {
|
||||
showModal("raw-email", { model });
|
||||
this.controllerFor("raw_email").loadRawEmail(model.get("id"));
|
||||
},
|
||||
|
||||
@action
|
||||
moveToTopic() {
|
||||
showModal("move-to-topic", {
|
||||
model: this.modelFor("topic"),
|
||||
title: "topic.move_to.title",
|
||||
});
|
||||
},
|
||||
|
||||
@action
|
||||
changeOwner() {
|
||||
showModal("change-owner", {
|
||||
model: this.modelFor("topic"),
|
||||
title: "topic.change_owner.title",
|
||||
});
|
||||
},
|
||||
|
||||
// Use replaceState to update the URL once it changes
|
||||
@action
|
||||
postChangedRoute(currentPost) {
|
||||
// do nothing if we are transitioning to another route
|
||||
if (this.isTransitioning || TopicRoute.disableReplaceState) {
|
||||
return;
|
||||
}
|
||||
|
||||
const topic = this.modelFor("topic");
|
||||
if (topic && currentPost) {
|
||||
let postUrl;
|
||||
if (currentPost > 1) {
|
||||
postUrl = topic.urlForPostNumber(currentPost);
|
||||
} else {
|
||||
postUrl = topic.url;
|
||||
}
|
||||
|
||||
showModal("edit-topic-timer", { model });
|
||||
this.controllerFor("modal").set("modalClass", "edit-topic-timer-modal");
|
||||
},
|
||||
if (this._router.currentRoute.queryParams) {
|
||||
let searchParams;
|
||||
|
||||
showTopicSlowModeUpdate() {
|
||||
const model = this.modelFor("topic");
|
||||
|
||||
showModal("edit-slow-mode", { model });
|
||||
},
|
||||
|
||||
showChangeTimestamp() {
|
||||
showModal("change-timestamp", {
|
||||
model: this.modelFor("topic"),
|
||||
title: "topic.change_timestamp.title",
|
||||
});
|
||||
},
|
||||
|
||||
showFeatureTopic() {
|
||||
showModal("featureTopic", {
|
||||
model: this.modelFor("topic"),
|
||||
title: "topic.feature_topic.title",
|
||||
});
|
||||
this.controllerFor("modal").set("modalClass", "feature-topic-modal");
|
||||
this.controllerFor("feature_topic").reset();
|
||||
},
|
||||
|
||||
showHistory(model, revision) {
|
||||
let historyController = showModal("history", {
|
||||
model,
|
||||
modalClass: "history-modal",
|
||||
});
|
||||
historyController.refresh(model.get("id"), revision || "latest");
|
||||
historyController.set("post", model);
|
||||
historyController.set("topicController", this.controllerFor("topic"));
|
||||
},
|
||||
|
||||
showGrantBadgeModal() {
|
||||
showModal("grant-badge", {
|
||||
model: this.modelFor("topic"),
|
||||
title: "admin.badges.grant_badge",
|
||||
});
|
||||
},
|
||||
|
||||
showRawEmail(model) {
|
||||
showModal("raw-email", { model });
|
||||
this.controllerFor("raw_email").loadRawEmail(model.get("id"));
|
||||
},
|
||||
|
||||
moveToTopic() {
|
||||
showModal("move-to-topic", {
|
||||
model: this.modelFor("topic"),
|
||||
title: "topic.move_to.title",
|
||||
});
|
||||
},
|
||||
|
||||
changeOwner() {
|
||||
showModal("change-owner", {
|
||||
model: this.modelFor("topic"),
|
||||
title: "topic.change_owner.title",
|
||||
});
|
||||
},
|
||||
|
||||
// Use replaceState to update the URL once it changes
|
||||
postChangedRoute(currentPost) {
|
||||
// do nothing if we are transitioning to another route
|
||||
if (this.isTransitioning || TopicRoute.disableReplaceState) {
|
||||
return;
|
||||
}
|
||||
|
||||
const topic = this.modelFor("topic");
|
||||
|
||||
if (topic && currentPost) {
|
||||
let postUrl;
|
||||
|
||||
if (currentPost > 1) {
|
||||
postUrl = topic.urlForPostNumber(currentPost);
|
||||
} else {
|
||||
postUrl = topic.url;
|
||||
}
|
||||
|
||||
if (this._router.currentRoute.queryParams) {
|
||||
let searchParams;
|
||||
|
||||
Object.entries(this._router.currentRoute.queryParams).map(
|
||||
([key, value]) => {
|
||||
if (!searchParams) {
|
||||
searchParams = new URLSearchParams();
|
||||
}
|
||||
|
||||
searchParams.append(key, value);
|
||||
Object.entries(this._router.currentRoute.queryParams).map(
|
||||
([key, value]) => {
|
||||
if (!searchParams) {
|
||||
searchParams = new URLSearchParams();
|
||||
}
|
||||
);
|
||||
|
||||
if (searchParams) {
|
||||
postUrl += `?${searchParams.toString()}`;
|
||||
searchParams.append(key, value);
|
||||
}
|
||||
);
|
||||
|
||||
if (searchParams) {
|
||||
postUrl += `?${searchParams.toString()}`;
|
||||
}
|
||||
|
||||
cancel(this.scheduledReplace);
|
||||
|
||||
this.setProperties({
|
||||
lastScrollPos: parseInt($(document).scrollTop(), 10),
|
||||
scheduledReplace: later(
|
||||
this,
|
||||
"_replaceUnlessScrolling",
|
||||
postUrl,
|
||||
Ember.Test ? 0 : SCROLL_DELAY
|
||||
),
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
didTransition() {
|
||||
const controller = this.controllerFor("topic");
|
||||
controller._showFooter();
|
||||
const topicId = controller.get("model.id");
|
||||
setTopicId(topicId);
|
||||
return true;
|
||||
},
|
||||
|
||||
willTransition() {
|
||||
this._super(...arguments);
|
||||
cancel(this.scheduledReplace);
|
||||
this.set("isTransitioning", true);
|
||||
return true;
|
||||
},
|
||||
|
||||
this.setProperties({
|
||||
lastScrollPos: parseInt($(document).scrollTop(), 10),
|
||||
scheduledReplace: later(
|
||||
this,
|
||||
"_replaceUnlessScrolling",
|
||||
postUrl,
|
||||
Ember.Test ? 0 : SCROLL_DELAY
|
||||
),
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@action
|
||||
didTransition() {
|
||||
const controller = this.controllerFor("topic");
|
||||
controller._showFooter();
|
||||
const topicId = controller.get("model.id");
|
||||
setTopicId(topicId);
|
||||
return true;
|
||||
},
|
||||
|
||||
@action
|
||||
willTransition() {
|
||||
this._super(...arguments);
|
||||
cancel(this.scheduledReplace);
|
||||
this.set("isTransitioning", true);
|
||||
return true;
|
||||
},
|
||||
|
||||
// replaceState can be very slow on Android Chrome. This function debounces replaceState
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "I18n";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
model() {
|
||||
|
@ -38,10 +39,9 @@ export default DiscourseRoute.extend({
|
|||
this.appEvents.off("draft:destroyed", this, this.refresh);
|
||||
},
|
||||
|
||||
actions: {
|
||||
didTransition() {
|
||||
this.controllerFor("user-activity")._showFooter();
|
||||
return true;
|
||||
},
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("user-activity")._showFooter();
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import UserBadge from "discourse/models/user-badge";
|
||||
import ViewingActionType from "discourse/mixins/viewing-action-type";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend(ViewingActionType, {
|
||||
model() {
|
||||
|
@ -19,10 +20,9 @@ export default DiscourseRoute.extend(ViewingActionType, {
|
|||
this.render("user/badges", { into: "user" });
|
||||
},
|
||||
|
||||
actions: {
|
||||
didTransition() {
|
||||
this.controllerFor("application").set("showFooter", true);
|
||||
return true;
|
||||
},
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("application").set("showFooter", true);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import Invite from "discourse/models/invite";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
model(params) {
|
||||
|
@ -26,9 +27,8 @@ export default DiscourseRoute.extend({
|
|||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
triggerRefresh() {
|
||||
this.refresh();
|
||||
},
|
||||
@action
|
||||
triggerRefresh() {
|
||||
this.refresh();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import ViewingActionType from "discourse/mixins/viewing-action-type";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend(ViewingActionType, {
|
||||
controllerName: "user-notifications",
|
||||
|
@ -9,11 +10,10 @@ export default DiscourseRoute.extend(ViewingActionType, {
|
|||
this.render("user/notifications");
|
||||
},
|
||||
|
||||
actions: {
|
||||
didTransition() {
|
||||
this.controllerFor("user-notifications")._showFooter();
|
||||
return true;
|
||||
},
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("user-notifications")._showFooter();
|
||||
return true;
|
||||
},
|
||||
|
||||
model(params) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "I18n";
|
||||
import User from "discourse/models/user";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
titleToken() {
|
||||
|
@ -10,14 +11,14 @@ export default DiscourseRoute.extend({
|
|||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
undoRevokeApiKey(key) {
|
||||
key.undoRevoke();
|
||||
},
|
||||
@action
|
||||
undoRevokeApiKey(key) {
|
||||
key.undoRevoke();
|
||||
},
|
||||
|
||||
revokeApiKey(key) {
|
||||
key.revoke();
|
||||
},
|
||||
@action
|
||||
revokeApiKey(key) {
|
||||
key.revoke();
|
||||
},
|
||||
|
||||
beforeModel() {
|
||||
|
|
|
@ -3,6 +3,7 @@ import I18n from "I18n";
|
|||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { Promise } from "rsvp";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
queryParams: {
|
||||
|
@ -55,10 +56,9 @@ export default DiscourseRoute.extend({
|
|||
]);
|
||||
},
|
||||
|
||||
actions: {
|
||||
didTransition() {
|
||||
this.controllerFor("users")._showFooter();
|
||||
return true;
|
||||
},
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("users")._showFooter();
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue