mirror of
https://github.com/discourse/discourse.git
synced 2024-12-12 13:43:41 +08:00
22521d3428
- `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.
37 lines
1.0 KiB
JavaScript
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);
|
|
}
|
|
}
|