This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/plugins/chat/assets/javascripts/discourse/models/user-chat-channel-membership.js
Joffrey JAFFEUX bef1966ca5
FIX: prevents creating a null User object (#19569)
Following the removal of user in current_user_membership we were now doing: `User.create(null)`.

I don't think it has any impact but this is just wasteful and could lead to issues if used.
2022-12-22 12:39:53 +10:00

29 lines
735 B
JavaScript

import RestModel from "discourse/models/rest";
import { tracked } from "@glimmer/tracking";
import User from "discourse/models/user";
export default class UserChatChannelMembership extends RestModel {
@tracked following = false;
@tracked muted = false;
@tracked unread_count = 0;
@tracked unread_mentions = 0;
@tracked desktop_notification_level = null;
@tracked mobile_notification_level = null;
@tracked last_read_message_id = null;
}
UserChatChannelMembership.reopenClass({
create(args) {
args = args || {};
this._initUser(args);
return this._super(args);
},
_initUser(args) {
if (!args.user || args.user instanceof User) {
return;
}
args.user = User.create(args.user);
},
});