UNPKG

agora-edu-core

Version:

Core APIs for building an online classroom

161 lines (155 loc) 5.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MessageItem = exports.HistoryChatMessage = exports.Conversation = void 0; var _mobx = require("mobx"); var _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7; function _initializerDefineProperty(e, i, r, l) { r && Object.defineProperty(e, i, { enumerable: r.enumerable, configurable: r.configurable, writable: r.writable, value: r.initializer ? r.initializer.call(l) : void 0 }); } function _applyDecoratedDescriptor(i, e, r, n, l) { var a = {}; return Object.keys(n).forEach(function (i) { a[i] = n[i]; }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = r.slice().reverse().reduce(function (r, n) { return n(i, e, r) || r; }, a), l && void 0 !== a.initializer && (a.value = a.initializer ? a.initializer.call(l) : void 0, a.initializer = void 0), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a; } function _initializerWarningHelper(r, e) { throw Error("Decorating class property failed. Please ensure that transform-class-properties is enabled and runs after the decorators transform."); } /** * 用户信息 */ /** @en * User info */ /** * 消息扩展信息 */ /** @en * Extra info of a chat message */ /** * 历史消息 */ /** @en * History message */ /** * 历史消息 */ /** @en * History message */ class HistoryChatMessage { constructor(data) { this.message = void 0; this.sendTime = void 0; this.sequences = void 0; this.fromUser = void 0; this.messageId = void 0; this.ext = void 0; this.message = data.message; this.sendTime = data.sendTime; this.sequences = data.sequences; this.messageId = data.messageId; this.fromUser = data.fromUser; this.ext = data.ext; } } /** * 聊天消息对象 */ /** @en * Message object */ exports.HistoryChatMessage = HistoryChatMessage; class MessageItem { constructor(data) { this.id = void 0; this.ts = void 0; this.messageId = void 0; this.content = void 0; this.role = void 0; this.isOwn = void 0; this.userName = void 0; this.unread = void 0; this.isBroadcast = void 0; this.id = data.id; this.ts = data.ts; this.messageId = data.messageId; this.role = data.role; this.isOwn = data.isOwn; this.unread = data.unread; this.userName = data.userName; this.content = data.content; this.isBroadcast = data.isBroadcast; } toMessage() { return { id: this.messageId, uid: this.id, userName: this.userName, role: `${this.role}`, //TODO timestamp: this.ts, content: this.content, isOwn: this.isOwn, unread: this.unread, isBroadcast: this.isBroadcast }; } } /** * 会话对象 */ /** @en * Conversation object */ exports.MessageItem = MessageItem; let Conversation = exports.Conversation = (_class = class Conversation { constructor(data) { _initializerDefineProperty(this, "userUuid", _descriptor, this); _initializerDefineProperty(this, "userName", _descriptor2, this); _initializerDefineProperty(this, "role", _descriptor3, this); _initializerDefineProperty(this, "lastMessageTs", _descriptor4, this); _initializerDefineProperty(this, "unreadMessageCount", _descriptor5, this); _initializerDefineProperty(this, "messages", _descriptor6, this); _initializerDefineProperty(this, "timestamp", _descriptor7, this); (0, _mobx.runInAction)(() => { this.userUuid = data.userUuid; this.userName = data.userName; this.role = data.role; this.lastMessageTs = data.lastMessageTs; this.unreadMessageCount = data.unreadMessageCount; this.messages = data.messages; this.timestamp = this.timestamp; }); } }, _descriptor = _applyDecoratedDescriptor(_class.prototype, "userUuid", [_mobx.observable], { configurable: true, enumerable: true, writable: true, initializer: null }), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "userName", [_mobx.observable], { configurable: true, enumerable: true, writable: true, initializer: null }), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "role", [_mobx.observable], { configurable: true, enumerable: true, writable: true, initializer: null }), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, "lastMessageTs", [_mobx.observable], { configurable: true, enumerable: true, writable: true, initializer: null }), _descriptor5 = _applyDecoratedDescriptor(_class.prototype, "unreadMessageCount", [_mobx.observable], { configurable: true, enumerable: true, writable: true, initializer: null }), _descriptor6 = _applyDecoratedDescriptor(_class.prototype, "messages", [_mobx.observable], { configurable: true, enumerable: true, writable: true, initializer: null }), _descriptor7 = _applyDecoratedDescriptor(_class.prototype, "timestamp", [_mobx.observable], { configurable: true, enumerable: true, writable: true, initializer: null }), _class);