Skip to content

A platform for community discussion. Free, open, simple.

REFACTOR: Remove `Discourse.Topic` constant

Robin Wardd74546f50efe
diff --git a/app/assets/javascripts/discourse/controllers/change-owner.js.es6 b/app/assets/javascripts/discourse/controllers/change-owner.js.es6
index 10ed05c04f0..9a738881d57 100644
--- a/app/assets/javascripts/discourse/controllers/change-owner.js.es6
+++ b/app/assets/javascripts/discourse/controllers/change-owner.js.es6
@@ -5,6 +5,7 @@ import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import DiscourseURL from "discourse/lib/url";
+import Topic from "discourse/models/topic";
import computed from "ember-addons/ember-computed-decorators";
export default Controller.extend(ModalFunctionality, {
@@ -37,10 +38,7 @@ export default Controller.extend(ModalFunctionality, {
username: this.new_user
};
- Discourse.Topic.changeOwners(
- this.get("topicController.model.id"),
- options
- ).then(
+ Topic.changeOwners(this.get("topicController.model.id"), options).then(
() => {
this.send("closeModal");
this.topicController.send("deselectAll");
diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6
index cbdba446231..ce4b607addf 100644
--- a/app/assets/javascripts/discourse/controllers/composer.js.es6
+++ b/app/assets/javascripts/discourse/controllers/composer.js.es6
@@ -758,8 +758,8 @@ export default Controller.extend({
@method open
@param {Object} opts Options for creating a post
@param {String} opts.action The action we're performing: edit, reply or createTopic
- @param {Discourse.Post} [opts.post] The post we're replying to
- @param {Discourse.Topic} [opts.topic] The topic we're replying to
+ @param {Post} [opts.post] The post we're replying to
+ @param {Topic} [opts.topic] The topic we're replying to
@param {String} [opts.quote] If we're opening a reply from a quote, the quote we're making
**/
open(opts) {
diff --git a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6
index 447e2ead37f..3d1d4b93484 100644
--- a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6
+++ b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6
@@ -8,6 +8,7 @@ import showModal from "discourse/lib/show-modal";
import { userPath } from "discourse/lib/url";
import TopicList from "discourse/models/topic-list";
import computed from "ember-addons/ember-computed-decorators";
+import Topic from "discourse/models/topic";
const controllerOpts = {
discovery: inject(),
@@ -83,7 +84,7 @@ const controllerOpts = {
resetNew() {
this.topicTrackingState.resetNew();
- Discourse.Topic.resetNew().then(() => this.send("refresh"));
+ Topic.resetNew().then(() => this.send("refresh"));
},
dismissReadPosts() {
diff --git a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6
index d2a809fc6ed..bd78a3002ba 100644
--- a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6
+++ b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6
@@ -1,6 +1,7 @@
import { empty, alias } from "@ember/object/computed";
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
+import Topic from "discourse/models/topic";
const _buttons = [];
@@ -88,7 +89,7 @@ export default Controller.extend(ModalFunctionality, {
this.set("loading", true);
const topics = this.get("model.topics");
- return Discourse.Topic.bulkOperation(topics, operation)
+ return Topic.bulkOperation(topics, operation)
.then(result => {
this.set("loading", false);
if (result && result.topic_ids) {
diff --git a/app/assets/javascripts/discourse/mixins/bulk-topic-selection.js.es6 b/app/assets/javascripts/discourse/mixins/bulk-topic-selection.js.es6
index 311e47661de..a4772fb594a 100644
--- a/app/assets/javascripts/discourse/mixins/bulk-topic-selection.js.es6
+++ b/app/assets/javascripts/discourse/mixins/bulk-topic-selection.js.es6
@@ -2,6 +2,7 @@ import { alias } from "@ember/object/computed";
import { NotificationLevels } from "discourse/lib/notification-levels";
import { on } from "ember-addons/ember-computed-decorators";
import Mixin from "@ember/object/mixin";
+import Topic from "discourse/models/topic";
export default Mixin.create({
bulkSelectEnabled: false,
@@ -33,9 +34,9 @@ export default Mixin.create({
let promise;
if (this.selected.length > 0) {
- promise = Discourse.Topic.bulkOperation(this.selected, operation);
+ promise = Topic.bulkOperation(this.selected, operation);
} else {
- promise = Discourse.Topic.bulkOperationByFilter(
+ promise = Topic.bulkOperationByFilter(
"unread",
operation,
this.get("category.id"),
diff --git a/app/assets/javascripts/discourse/models/category-list.js.es6 b/app/assets/javascripts/discourse/models/category-list.js.es6
index aff72e7fa30..227dc148943 100644
--- a/app/assets/javascripts/discourse/models/category-list.js.es6
+++ b/app/assets/javascripts/discourse/models/category-list.js.es6
@@ -1,5 +1,6 @@
import PreloadStore from "preload-store";
import { ajax } from "discourse/lib/ajax";
+import Topic from "discourse/models/topic";
const CategoryList = Ember.ArrayProxy.extend({
init() {
@@ -39,7 +40,7 @@ CategoryList.reopenClass({
if (c.topics) {
c.topics = c.topics.map(t => {
- const topic = Discourse.Topic.create(t);
+ const topic = Topic.create(t);
topic.set("category", c);
return topic;
});
diff --git a/app/assets/javascripts/discourse/models/user-badge.js.es6 b/app/assets/javascripts/discourse/models/user-badge.js.es6
index 69e88caf2ef..511ed71de20 100644
--- a/app/assets/javascripts/discourse/models/user-badge.js.es6
+++ b/app/assets/javascripts/discourse/models/user-badge.js.es6
@@ -2,6 +2,7 @@ import { ajax } from "discourse/lib/ajax";
import Badge from "discourse/models/badge";
import computed from "ember-addons/ember-computed-decorators";
import { Promise } from "rsvp";
+import Topic from "discourse/models/topic";
const UserBadge = Discourse.Model.extend({
@computed
@@ -35,7 +36,7 @@ UserBadge.reopenClass({
}
var topics = {};
json.topics.forEach(function(topicJson) {
- topics[topicJson.id] = Discourse.Topic.create(topicJson);
+ topics[topicJson.id] = Topic.create(topicJson);
});
// Create the badges.
diff --git a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb
index dd9392764d8..ee18d1d6d27 100644
--- a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb
+++ b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb
@@ -93,7 +93,6 @@ JS
"discourse/models/user",
"discourse/models/session",
"discourse/models/model",
- "discourse/models/topic",
"discourse/models/post",
"discourse/views/grouped"]
)