IConversationModel

IConversationModel

Properties:
Name Type Description
conversationID String

Conversation ID. Composition of conversation ID:

  • C2C${userID} (single chat)
  • GROUP${groupID} (group chat)
  • @TIM#SYSTEM (system notification conversation)
type String

Conversation type, as follows:

Type Meaning
TUIChatEngine.TYPES.CONV_C2C C2C (Client to Client) conversation
TUIChatEngine.TYPES.CONV_GROUP GROUP conversation
TUIChatEngine.TYPES.CONV_SYSTEM SYSTEM conversation. This conversation can only receive system notification messages and cannot send messages.
subType String

Group conversation type, as follows:

Type Meaning
TUIChatEngine.TYPES.GRP_WORK Work group
TUIChatEngine.TYPES.GRP_PUBLIC Public group
TUIChatEngine.TYPES.GRP_MEETING Temporary meeting group
TUIChatEngine.TYPES.GRP_AVCHATROOM Live streaming group
unreadCount Number

Unread message count. TUIChatEngine.TYPES.GRP_MEETING / TUIChatEngine.TYPES.GRP_AVCHATROOM group conversations do not track unread counts, this field will be 0.

lastMessage Object

The latest message in the conversation

Properties
Name Type Description
nick String

Nickname of the sender in group conversations, empty for C2C conversations

nameCard String

Group name card of the sender in group conversations, empty for C2C conversations

lastTime Number

Timestamp of the latest message in the conversation, in seconds

lastSequence Number

Sequence number of the latest message in the conversation

fromAccount String

UserID of the sender of the latest message

isRevoked Boolean

Whether the latest message has been revoked, true means revoked, default is false

revoker String | null

UserID of the message revoker

isPeerRead Boolean

Whether the peer has read the latest message in C2C conversation, default is false

messageForShow String

Content of the latest message for display. Possible values: text message content, "[Image]", "[Voice]", "[Location]", "[Emoji]", "[File]", "[Custom Message]".
If this field doesn't meet your needs, you can use payload for custom rendering.

type String

Message type, as follows:

Type Meaning
TUIChatEngine.TYPES.MSG_TEXT Text message
TUIChatEngine.TYPES.MSG_IMAGE Image message
TUIChatEngine.TYPES.MSG_SOUND Audio message
TUIChatEngine.TYPES.MSG_AUDIO Audio message
TUIChatEngine.TYPES.MSG_VIDEO Video message
TUIChatEngine.TYPES.MSG_FILE File message
TUIChatEngine.TYPES.MSG_LOCATION Location message
TUIChatEngine.TYPES.MSG_CUSTOM Custom message
TUIChatEngine.TYPES.MSG_GRP_TIP Group tip message
TUIChatEngine.TYPES.MSG_GRP_SYS_NOTICE Group system notification message
payload Object

Message content. Received audio/file messages' payload won't have url field.

groupProfile Group

Group profile for group conversations

userProfile Profile

User profile for C2C conversations

groupAtInfoList Array.<GroupAtInfo>

Group @ information list. Developers can use this to display effects like "@me" or "@all" in conversation list.

remark String

Friend remark. Only available for C2C conversations where the peer is my friend and I've set a remark for this friend.

isPinned Boolean

Whether the conversation is pinned

messageRemindType String

Message reminder type, as follows:

  • TUIChatEngine.TYPES.MSG_REMIND_ACPT_AND_NOTE Receive messages normally when online, with offline push notifications when offline (Web and mini-program don't have offline push)
  • TUIChatEngine.TYPES.MSG_REMIND_DISCARD Reject messages both online and offline
  • TUIChatEngine.TYPES.MSG_REMIND_ACPT_NOT_NOTE Receive messages normally when online, no push notifications when offline (Do Not Disturb)
markList Array

Conversation mark list, as follows:

  • TUIChatEngine.TYPES.CONV_MARK_TYPE_STAR Starred conversation
  • TUIChatEngine.TYPES.CONV_MARK_TYPE_UNREAD Marked as unread (important conversation)
  • TUIChatEngine.TYPES.CONV_MARK_TYPE_FOLD Folded conversation
  • TUIChatEngine.TYPES.CONV_MARK_TYPE_HIDE Hidden conversation
customData String

Conversation custom data

conversationGroupList Array

Conversation group list

draftText String

Conversation draft

isMuted Boolean

Whether the conversation is muted, default is false

operationType Number

Group operation type, default 0. 4-Removed from group 5-Group disbanded 8-Left group actively

ConversationModel is mainly responsible for conversation operations and data processing. Developers don't need to implement ConversationModel themselves, as it is provided by TUIChatEngine through ConversationStore's conversationList for direct use.

Methods

deleteConversation() → {Promise.<any>}

Delete conversation

Example
let promise = conversationModel.deleteConversation();
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling when calls fail
});
Returns:
Type
Promise.<any>

pinConversation() → {Promise.<any>}

Pin conversation

Examples
// Pin conversation
// When isPinned is false, calling this API pins the conversation
if (isPinned === false) {
 let promise = conversationModel.pinConversation();
 promise.catch((error) => {
   // Business side can catch exceptions through promise.catch for error handling when calls fail
 });
}
// Unpin conversation
// When isPinned is true, calling this API unpins the conversation.
if (isPinned === true) {
 let promise = conversationModel.pinConversation();
 promise.catch((error) => {
   // Business side can catch exceptions through promise.catch for error handling when calls fail
 });
}
Returns:
Type
Promise.<any>

muteConversation() → {Promise.<any>}

Set message Do Not Disturb

Examples
// Set message Do Not Disturb
// When isMuted is false, calling this API sets message Do Not Disturb.
let promise = conversationModel.muteConversation();
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling when calls fail
});
// Cancel message Do Not Disturb
// When isMuted is true, calling this API cancels message Do Not Disturb.
let promise = conversationModel.muteConversation();
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling when calls fail
});
Returns:
Type
Promise.<any>

getAvatar() → {string}

Get conversation avatar

Example
let avatar = conversationModel.getAvatar();
Returns:
Type
string

getShowName() → {string}

Get conversation display name

Example
let name = conversationModel.getShowName();
Returns:
Type
string

getGroupAtInfo() → {string}

Get group @ information

Example
let atInfo = conversationModel.getGroupAtInfo();
Returns:
Type
string

getLastMessage(key) → {string|null}

Get display information of the latest message in conversation

Examples
// Get display time of lastMessage
let time = conversationModel.getLastMessage('time');
// Get display text content of lastMessage
let time = conversationModel.getLastMessage('text');
Parameters:
Name Type Description
key string

The key of lastMessage to be displayed

  • time Get display time of lastMessage
  • text Get display text of lastMessage
Returns:
Type
string | null