REFACTOR: Remove `Discourse.UserAction` from code
This commit is contained in:
parent
1990baa457
commit
779ee3558d
|
@ -19,7 +19,7 @@ export default RestModel.extend({
|
|||
|
||||
@discourseComputed("filter")
|
||||
filterParam(filter) {
|
||||
if (filter === Discourse.UserAction.TYPES.replies) {
|
||||
if (filter === UserAction.TYPES.replies) {
|
||||
return [UserAction.TYPES.replies, UserAction.TYPES.quotes].join(",");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import UserTopicListRoute from "discourse/routes/user-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
|
||||
export default (viewName, path, channel) => {
|
||||
return UserTopicListRoute.extend({
|
||||
userActionType: Discourse.UserAction.TYPES.messages_received,
|
||||
userActionType: UserAction.TYPES.messages_received,
|
||||
|
||||
titleToken() {
|
||||
const key = viewName === "index" ? "inbox" : viewName;
|
||||
|
|
|
@ -86,7 +86,6 @@ JS
|
|||
|
||||
@@whitelisted ||= Set.new(
|
||||
["discourse/models/nav-item",
|
||||
"discourse/models/user-action",
|
||||
"discourse/routes/discourse",
|
||||
"discourse/models/category",
|
||||
"discourse/models/site",
|
||||
|
|
|
@ -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 => {
|
||||
var actions = Discourse.UserAction.collapseStream([
|
||||
Discourse.UserAction.create({
|
||||
action_type: Discourse.UserAction.TYPES.likes_given,
|
||||
var actions = UserAction.collapseStream([
|
||||
UserAction.create({
|
||||
action_type: UserAction.TYPES.likes_given,
|
||||
topic_id: 1,
|
||||
user_id: 1,
|
||||
post_number: 1
|
||||
}),
|
||||
Discourse.UserAction.create({
|
||||
action_type: Discourse.UserAction.TYPES.edits,
|
||||
UserAction.create({
|
||||
action_type: UserAction.TYPES.edits,
|
||||
topic_id: 2,
|
||||
user_id: 1,
|
||||
post_number: 1
|
||||
}),
|
||||
Discourse.UserAction.create({
|
||||
action_type: Discourse.UserAction.TYPES.likes_given,
|
||||
UserAction.create({
|
||||
action_type: UserAction.TYPES.likes_given,
|
||||
topic_id: 1,
|
||||
user_id: 2,
|
||||
post_number: 1
|
||||
|
@ -23,7 +25,6 @@ QUnit.test("collapsing likes", assert => {
|
|||
]);
|
||||
|
||||
assert.equal(actions.length, 2);
|
||||
|
||||
assert.equal(actions[0].get("children.length"), 1);
|
||||
assert.equal(actions[0].get("children")[0].items.length, 2);
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import UserAction from "discourse/models/user-action";
|
||||
|
||||
QUnit.module("Discourse.UserStream");
|
||||
|
||||
QUnit.test("basics", assert => {
|
||||
|
@ -20,12 +22,9 @@ QUnit.test("filterParam", assert => {
|
|||
// defaults to posts/topics
|
||||
assert.equal(stream.get("filterParam"), "4,5");
|
||||
|
||||
stream.set("filter", Discourse.UserAction.TYPES.likes_given);
|
||||
assert.equal(
|
||||
stream.get("filterParam"),
|
||||
Discourse.UserAction.TYPES.likes_given
|
||||
);
|
||||
stream.set("filter", UserAction.TYPES.likes_given);
|
||||
assert.equal(stream.get("filterParam"), UserAction.TYPES.likes_given);
|
||||
|
||||
stream.set("filter", Discourse.UserAction.TYPES.replies);
|
||||
stream.set("filter", UserAction.TYPES.replies);
|
||||
assert.equal(stream.get("filterParam"), "6,9");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue