mirror of
https://github.com/hanzoai/forum.git
synced 2026-09-30 21:51:19 +00:00
* remove default prop values where they're being set in constructor * replace some `||` operators in constructors with `??` so the fallback boolean values are actually used
36 lines
797 B
JavaScript
36 lines
797 B
JavaScript
import { tracked } from "@glimmer/tracking";
|
|
import { TrackedArray } from "@ember-compat/tracked-built-ins";
|
|
import User from "discourse/models/user";
|
|
|
|
export const REACTIONS = { add: "add", remove: "remove" };
|
|
|
|
export default class ChatMessageReaction {
|
|
static create(args = {}) {
|
|
return new ChatMessageReaction(args);
|
|
}
|
|
|
|
@tracked count;
|
|
@tracked reacted;
|
|
@tracked users;
|
|
@tracked emoji;
|
|
|
|
constructor(args = {}) {
|
|
this.count = args.count;
|
|
this.emoji = args.emoji;
|
|
this.reacted = args.reacted;
|
|
this.users = this.#initUsersModels(args.users);
|
|
}
|
|
|
|
#initUsersModels(users = []) {
|
|
return new TrackedArray(
|
|
users.map((user) => {
|
|
if (user instanceof User) {
|
|
return user;
|
|
}
|
|
|
|
return User.create(user);
|
|
})
|
|
);
|
|
}
|
|
}
|