discourse/plugins/chat/assets/javascripts/discourse/models/user-chat-channel-membership.js
Joffrey JAFFEUX 22521d3428
DEV: converts models to native classes (#21418)
- `ChatChannel`
- `UserChatChannelMembership`

Also creates a new `chat-direct-message` model used as the object for the`chatable` property of the `ChatChannel` when the `ChatChannel` is a direct message channel. When the chatable is a category a real `Category` object will now be returned.

Archive state of a `ChatChannel` is now hold in a `ChatChannelArchive` object.
2023-05-08 18:24:41 +02:00

37 lines
1.0 KiB
JavaScript

import { tracked } from "@glimmer/tracking";
import User from "discourse/models/user";
export default class UserChatChannelMembership {
static create(args = {}) {
return new UserChatChannelMembership(args);
}
@tracked following = false;
@tracked muted = false;
@tracked unreadCount = 0;
@tracked unreadMentions = 0;
@tracked desktopNotificationLevel = null;
@tracked mobileNotificationLevel = null;
@tracked lastReadMessageId = null;
@tracked user = null;
constructor(args = {}) {
this.following = args.following;
this.muted = args.muted;
this.unreadCount = args.unread_count;
this.unreadMentions = args.unread_mentions;
this.desktopNotificationLevel = args.desktop_notification_level;
this.mobileNotificationLevel = args.mobile_notification_level;
this.lastReadMessageId = args.last_read_message_id;
this.user = this.#initUserModel(args.user);
}
#initUserModel(user) {
if (!user || user instanceof User) {
return user;
}
return User.create(user);
}
}