Skip to content

Commit

Permalink
DEV: Convert to native class syntax (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaylorhq authored Nov 29, 2024
1 parent 35b59bd commit 101305c
Showing 1 changed file with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ import RestModel from "discourse/models/rest";
import Topic from "discourse/models/topic";
import User from "discourse/models/user";

const CustomReaction = RestModel.extend({
init() {
this._super(...arguments);

this.__type = "discourse-reactions-custom-reaction";
},
});

CustomReaction.reopenClass({
toggle(post, reactionId) {
export default class CustomReaction extends RestModel {
static toggle(post, reactionId) {
return ajax(
`/discourse-reactions/posts/${post.id}/custom-reactions/${reactionId}/toggle.json`,
{ type: "PUT" }
Expand All @@ -25,9 +17,9 @@ CustomReaction.reopenClass({
reaction: result.current_user_reaction,
});
});
},
}

findReactions(url, username, opts) {
static findReactions(url, username, opts) {
opts = opts || {};
const data = { username };

Expand Down Expand Up @@ -63,9 +55,9 @@ CustomReaction.reopenClass({
return EmberObject.create(reaction);
});
});
},
}

findReactionUsers(postId, opts) {
static findReactionUsers(postId, opts) {
opts = opts || {};
const data = {};

Expand All @@ -76,7 +68,10 @@ CustomReaction.reopenClass({
return ajax(`/discourse-reactions/posts/${postId}/reactions-users.json`, {
data,
});
},
});
}

export default CustomReaction;
init() {
super.init(...arguments);
this.__type = "discourse-reactions-custom-reaction";
}
}

0 comments on commit 101305c

Please sign in to comment.