UNPKG

tjc-sdk

Version:

TIANJI IM SDK

2 lines (1 loc) 1.55 kB
import t from"./conversation.js";import e from"../messages/message.js";import s from"../client/tjc.js";import{eq as r}from"../util/longUtil.js";import i from"./conversationType.js";class a{conversation={};lastMessage={};timestamp=0;draft="";unreadCount={};top=0;isSilent=!1;target;static protoConversationToConversationInfo(s){let r=Object.assign(new a,s);return r.top=s.isTop,delete r.isTop,s.conversation?r.conversation=new t(s.conversation.type,s.conversation.target,s.conversation.line):r.conversation=new t(s.conversationType,s.target,s.line),r.lastMessage=e.fromProtoMessage(s.lastMessage),r.timestamp||(r.timestamp=0),r}portrait(){let t="";switch(this.conversation.type){case i.Single:t=s.getUserInfo(this.conversation.target,!1).portrait;break;case i.Group:t=s.getGroupInfo(this.conversation.target,!1).portrait;case i.Channel:case i.ChatRoom:}return t}title(){let t=this.conversation.target;switch(this.conversation.type){case i.Single:t=s.getUserDisplayName(this.conversation.target);break;case i.Group:t=s.getGroupInfo(this.conversation.target,!1).name;case i.ChatRoom:case i.Channel:}return t}static equals(t,e){if(!t||!e)return!1;if(!t.conversation.equal(e.conversation))return!1;let s=t.unreadCount,i=e.unreadCount;return s.unread===i.unread&&s.unreadMention===i.unreadMention&&s.unreadMentionAll===i.unreadMentionAll&&!(t.lastMessage&&!e.lastMessage||!t.lastMessage&&e.lastMessage)&&(!t.lastMessage||!e.lastMessage||t.lastMessage.messageId===e.lastMessage.messageId)&&r(t.timestamp,e.timestamp)&&t.draft===e.draft}}export{a as default};