diff --git a/sdk/javascript/delivery-read-receipts.mdx b/sdk/javascript/delivery-read-receipts.mdx index 7f3382d9..464e319f 100644 --- a/sdk/javascript/delivery-read-receipts.mdx +++ b/sdk/javascript/delivery-read-receipts.mdx @@ -224,6 +224,83 @@ CometChat.markAsDelivered(message).then( +## Mark Conversation as Delivered + +You can mark an entire conversation as delivered for a user or group using the `markConversationAsDelivered()` method. This method takes the below parameters as input: + +| Parameter | Information | +| ------------------ | ------------------------------------------------------------------------------ | +| `conversationWith` | The ID of the user (UID) or group (GUID) for the conversation. | +| `conversationType` | Type of the conversation. Could be either `user` or `group`. | + +This method will mark all messages in the conversation as delivered. + + + +```javascript +var conversationWith = "USER_UID"; +var conversationType = "user"; + +CometChat.markConversationAsDelivered(conversationWith, conversationType).then( + (response) => { + console.log("Conversation marked as delivered", response); + }, + (error) => { + console.log("Error marking conversation as delivered", error); + } +); +``` + + + +```javascript +var conversationWith = "GROUP_GUID"; +var conversationType = "group"; + +CometChat.markConversationAsDelivered(conversationWith, conversationType).then( + (response) => { + console.log("Conversation marked as delivered", response); + }, + (error) => { + console.log("Error marking conversation as delivered", error); + } +); +``` + + + +```typescript +var conversationWith: string = "USER_UID"; +var conversationType: string = "user"; + +CometChat.markConversationAsDelivered(conversationWith, conversationType).then( + (response: string) => { + console.log("Conversation marked as delivered", response); + }, + (error: CometChat.CometChatException) => { + console.log("Error marking conversation as delivered", error); + } +); +``` + + + +```typescript +var conversationWith: string = "GROUP_GUID"; +var conversationType: string = "group"; + +CometChat.markConversationAsDelivered(conversationWith, conversationType).then( + (response: string) => { + console.log("Conversation marked as delivered", response); + }, + (error: CometChat.CometChatException) => { + console.log("Error marking conversation as delivered", error); + } +); +``` + + + ## Mark Messages as Read *In other words, as a recipient, how do I inform the sender I've read a message?* @@ -425,25 +502,105 @@ CometChat.markAsRead(message).then( +## Mark Conversation as Read + +You can mark an entire conversation as read for a user or group using the `markConversationAsRead()` method. This method takes the below parameters as input: + +| Parameter | Information | +| ------------------ | ------------------------------------------------------------------------------ | +| `conversationWith` | The ID of the user (UID) or group (GUID) for the conversation. | +| `conversationType` | Type of the conversation. Could be either `user` or `group`. | + +This method will mark all messages in the conversation as read. + + + +```javascript +var conversationWith = "USER_UID"; +var conversationType = "user"; + +CometChat.markConversationAsRead(conversationWith, conversationType).then( + (response) => { + console.log("Conversation marked as read", response); + }, + (error) => { + console.log("Error marking conversation as read", error); + } +); +``` + + + +```javascript +var conversationWith = "GROUP_GUID"; +var conversationType = "group"; + +CometChat.markConversationAsRead(conversationWith, conversationType).then( + (response) => { + console.log("Conversation marked as read", response); + }, + (error) => { + console.log("Error marking conversation as read", error); + } +); +``` + + + +```typescript +var conversationWith: string = "USER_UID"; +var conversationType: string = "user"; + +CometChat.markConversationAsRead(conversationWith, conversationType).then( + (response: string) => { + console.log("Conversation marked as read", response); + }, + (error: CometChat.CometChatException) => { + console.log("Error marking conversation as read", error); + } +); +``` + + + +```typescript +var conversationWith: string = "GROUP_GUID"; +var conversationType: string = "group"; + +CometChat.markConversationAsRead(conversationWith, conversationType).then( + (response: string) => { + console.log("Conversation marked as read", response); + }, + (error: CometChat.CometChatException) => { + console.log("Error marking conversation as read", error); + } +); +``` + + + ## Mark Messages as Unread -The Mark as Unread feature allows users to designate specific messages or conversations as unread, even if they have been previously viewed. +The Mark messages as Unread feature allows users to designate specific messages or conversations as unread, even if they have been previously viewed. This feature is valuable for users who want to revisit and respond to important messages or conversations later, ensuring they don't forget or overlook them. In other words, how I can mark a message as unread? -You can mark the messages for a particular conversation as unread using the `markAsUnread()` method. This method takes the below parameters as input: +You can mark the messages for a particular conversation as unread using the `markMessageAsUnread()` method. This method takes the below parameters as input: | Parameter | Information | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| message | To mark a message as unread, pass a non-null `BaseMessage` instance to the `markAsUnread()` function. All messages below that message in the conversation will contribute to the unread messages count. Example: When User B sends User A a total of 10 messages, and User A invokes the `markAsUnread()` method on the fifth message, all messages located below the fifth message within the conversation list will be designated as unread. This results in a notification indicating there are 5 unread messages in the conversation list. | -| listener | The callback listener that will be called on success or error. This should be a non-null `CallbackListener` instance. | +| message | To mark a message as unread, pass a non-null `BaseMessage` instance to the `markMessageAsUnread()` function. All messages below that message in the conversation will contribute to the unread messages count. Example: When User B sends User A a total of 10 messages, and User A invokes the `markMessageAsUnread()` method on the fifth message, all messages located below the fifth message within the conversation list will be designated as unread. This results in a notification indicating there are 5 unread messages in the conversation list. | + + +You cannot mark your own messages as unread. This method only works for messages received from other users. + - + ```javascript -CometChat.markAsUnread(message); +CometChat.markMessageAsUnread(message); ``` @@ -451,21 +608,22 @@ CometChat.markAsUnread(message); ```typescript let message: CometChat.BaseMessage; -CometChat.markAsUnread(message); +CometChat.markMessageAsUnread(message); ``` -In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback).` +In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback).` On success, this method returns an updated `Conversation` object with the updated unread message count and other conversation data. - + ```javascript -CometChat.markAsUnread(message).then( - () => { - console.log("mark as unread success."); +CometChat.markMessageAsUnread(message).then( + (conversation) => { + console.log("mark messages as unread success.", conversation); + console.log("Unread message count:", conversation.getUnreadMessageCount()); }, (error) => { console.log("An error occurred when marking the message as unread.", error); @@ -478,12 +636,13 @@ CometChat.markAsUnread(message).then( ```typescript let message: CometChat.BaseMessage; -CometChat.markAsUnread(message).then( - () => { - console.log("mark as read success."); +CometChat.markMessageAsUnread(message).then( + (conversation: CometChat.Conversation) => { + console.log("mark messages as unread success.", conversation); + console.log("Unread message count:", conversation.getUnreadMessageCount()); }, (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as read.", error); + console.log("An error occurred when marking the message as unread.", error); } ); ``` @@ -629,6 +788,6 @@ The following features will be available only if the **Enhanced Messaging Status * `onMessagesReadByAll` event, * `deliveredAt` field in a group message, * `readAt` field in a group message. -* `markAsUnread` method. +* `markMessageAsUnread` method.