REFACTOR: Remove Discourse.UserAction from code

This commit is contained in:
Robin Ward 2019-11-08 12:52:39 -05:00
parent 1990baa457
commit 779ee3558d
5 changed files with 18 additions and 18 deletions

View File

@ -19,7 +19,7 @@ export default RestModel.extend({
@discourseComputed("filter") @discourseComputed("filter")
filterParam(filter) { filterParam(filter) {
if (filter === Discourse.UserAction.TYPES.replies) { if (filter === UserAction.TYPES.replies) {
return [UserAction.TYPES.replies, UserAction.TYPES.quotes].join(","); return [UserAction.TYPES.replies, UserAction.TYPES.quotes].join(",");
} }

View File

@ -1,10 +1,11 @@
import UserTopicListRoute from "discourse/routes/user-topic-list"; import UserTopicListRoute from "discourse/routes/user-topic-list";
import { findOrResetCachedTopicList } from "discourse/lib/cached-topic-list"; import { findOrResetCachedTopicList } from "discourse/lib/cached-topic-list";
import UserAction from "discourse/models/user-action";
// A helper to build a user topic list route // A helper to build a user topic list route
export default (viewName, path, channel) => { export default (viewName, path, channel) => {
return UserTopicListRoute.extend({ return UserTopicListRoute.extend({
userActionType: Discourse.UserAction.TYPES.messages_received, userActionType: UserAction.TYPES.messages_received,
titleToken() { titleToken() {
const key = viewName === "index" ? "inbox" : viewName; const key = viewName === "index" ? "inbox" : viewName;

View File

@ -86,7 +86,6 @@ JS
@@whitelisted ||= Set.new( @@whitelisted ||= Set.new(
["discourse/models/nav-item", ["discourse/models/nav-item",
"discourse/models/user-action",
"discourse/routes/discourse", "discourse/routes/discourse",
"discourse/models/category", "discourse/models/category",
"discourse/models/site", "discourse/models/site",

View File

@ -1,21 +1,23 @@
QUnit.module("Discourse.UserAction"); import UserAction from "discourse/models/user-action";
QUnit.module("model: user-action");
QUnit.test("collapsing likes", assert => { QUnit.test("collapsing likes", assert => {
var actions = Discourse.UserAction.collapseStream([ var actions = UserAction.collapseStream([
Discourse.UserAction.create({ UserAction.create({
action_type: Discourse.UserAction.TYPES.likes_given, action_type: UserAction.TYPES.likes_given,
topic_id: 1, topic_id: 1,
user_id: 1, user_id: 1,
post_number: 1 post_number: 1
}), }),
Discourse.UserAction.create({ UserAction.create({
action_type: Discourse.UserAction.TYPES.edits, action_type: UserAction.TYPES.edits,
topic_id: 2, topic_id: 2,
user_id: 1, user_id: 1,
post_number: 1 post_number: 1
}), }),
Discourse.UserAction.create({ UserAction.create({
action_type: Discourse.UserAction.TYPES.likes_given, action_type: UserAction.TYPES.likes_given,
topic_id: 1, topic_id: 1,
user_id: 2, user_id: 2,
post_number: 1 post_number: 1
@ -23,7 +25,6 @@ QUnit.test("collapsing likes", assert => {
]); ]);
assert.equal(actions.length, 2); assert.equal(actions.length, 2);
assert.equal(actions[0].get("children.length"), 1); assert.equal(actions[0].get("children.length"), 1);
assert.equal(actions[0].get("children")[0].items.length, 2); assert.equal(actions[0].get("children")[0].items.length, 2);
}); });

View File

@ -1,3 +1,5 @@
import UserAction from "discourse/models/user-action";
QUnit.module("Discourse.UserStream"); QUnit.module("Discourse.UserStream");
QUnit.test("basics", assert => { QUnit.test("basics", assert => {
@ -20,12 +22,9 @@ QUnit.test("filterParam", assert => {
// defaults to posts/topics // defaults to posts/topics
assert.equal(stream.get("filterParam"), "4,5"); assert.equal(stream.get("filterParam"), "4,5");
stream.set("filter", Discourse.UserAction.TYPES.likes_given); stream.set("filter", UserAction.TYPES.likes_given);
assert.equal( assert.equal(stream.get("filterParam"), UserAction.TYPES.likes_given);
stream.get("filterParam"),
Discourse.UserAction.TYPES.likes_given
);
stream.set("filter", Discourse.UserAction.TYPES.replies); stream.set("filter", UserAction.TYPES.replies);
assert.equal(stream.get("filterParam"), "6,9"); assert.equal(stream.get("filterParam"), "6,9");
}); });