TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED
.chat.setConversationCustomData(options);
options
parameter is of the Object
type. It contains the following attribute values:Name | Type | Description |
conversationIDList | String | List of conversation IDs |
customData | String | Custom data, with a maximum length support of 256 bytes. Setting it to '' will clear the conversation custom data. |
Promise
let promise = chat.setConversationCustomData({conversationIDList: ['GROUPtest', 'C2Cexample'],customData: 'your custom data'});promise.then(function(imResponse) {const { successConversationIDList, failureConversationIDList } = imResponse.data;const conversationList = chat.getConversationList(successConversationIDList);failureConversationIDList.forEach((item) => {const { conversationID, code, message } = item;});}).catch(function(imError) {console.warn('setConversationCustomData error:', imError);});
// clear the conversation custom data.let promise = chat.setConversationCustomData({conversationIDList: ['GROUPtest', 'C2Cexample'],customData: ''});promise.then(function(imResponse) {const { successConversationIDList, failureConversationIDList } = imResponse.data;const conversationList = chat.getConversationList(successConversationIDList);failureConversationIDList.forEach((item) => {const { conversationID, code, message } = item;});}).catch(function(imError) {console.warn('setConversationCustomData error:', imError);});
markConversation
API to mark or unmark a conversation.TencentCloud.TYPES.CONV_MARK_TYPE_UNREAD
does not alter the unread count at the underlying layer.chat.markConversation(options);
options
parameter is of the Object
type. It contains the following attribute values:Name | Type | Description |
conversationIDList | String | List of conversation IDs |
markType | Number | Conversation mark type |
enableMark | Boolean | true : Mark.false : Unmark |
Promise
// Mark a conversation as "favorite"let promise = chat.markConversation({conversationIDList: ['GROUPtest', 'C2Cexample'],markType: TencentCloudChat.TYPES.CONV_MARK_TYPE_STAR,enableMark: true});promise.then(function(imResponse) {// Marked the conversation as "favorite" successfullyconst { successConversationIDList, failureConversationIDList } = imResponse.data;// successConversationIDList - List of conversations that were marked successfully// Get the conversation listconst conversationList = chat.getConversationList(successConversationIDList);// failureConversationIDList - List of conversations that failed to be marked as "favorite"failureConversationIDList.forEach((item) => {const { conversationID, code, message } = item;});}).catch(function(imError){console.warn('markConversation error:', imError);});
markList
field in Conversation
will change. You can listen for such a change notification through the TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED
event.let onConversationListUpdated = function(event) {console.log(event.data); // Array that stores Conversation instances};chat.on(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED, onConversationListUpdated);
getConversationList
API to pull a specified marked conversation.// Obtain all conversations that are marked as "favorite"let promise = chat.getConversationList({ markType: TencentCloudChat.TYPES.CONV_MARK_TYPE_STAR });promise.then(function(imResponse) {const conversationList = imResponse.data.conversationList; // Conversation list});
// Obtain all one-to-one conversations that are marked as "collapsed"let promise = chat.getConversationList({markType: TencentCloudChat.TYPES.CONV_MARK_TYPE_FOLD,type: TencentCloudChat.TYPES.CONV_C2C});promise.then(function(imResponse) {const conversationList = imResponse.data.conversationList; // Conversation list});
Was this page helpful?