Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 176 additions & 17 deletions sdk/javascript/delivery-read-receipts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,83 @@ CometChat.markAsDelivered(message).then(

</Tabs>

## 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.

<Tabs>
<Tab title="User">
```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);
}
);
```
</Tab>

<Tab title="Group">
```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);
}
);
```
</Tab>

<Tab title="User(TypeScript)">
```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);
}
);
```
</Tab>

<Tab title="Group(TypeScript)">
```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);
}
);
```
</Tab>
</Tabs>

## Mark Messages as Read

*In other words, as a recipient, how do I inform the sender I've read a message?*
Expand Down Expand Up @@ -425,47 +502,128 @@ CometChat.markAsRead(message).then(

</Tabs>

## 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.

<Tabs>
<Tab title="User">
```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);
}
);
```
</Tab>

<Tab title="Group">
```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);
}
);
```
</Tab>

<Tab title="User(TypeScript)">
```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);
}
);
```
</Tab>

<Tab title="Group(TypeScript)">
```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);
}
);
```
</Tab>
</Tabs>

## 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. |

<Note>
You cannot mark your own messages as unread. This method only works for messages received from other users.
</Note>

<Tabs>
<Tab title="Mark as Unread">
<Tab title="Mark Messages as Unread">
```javascript
CometChat.markAsUnread(message);
CometChat.markMessageAsUnread(message);
```

</Tab>

<Tab title="TypeScript">
```typescript
let message: CometChat.BaseMessage;
CometChat.markAsUnread(message);
CometChat.markMessageAsUnread(message);
```

</Tab>

</Tabs>

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.

<Tabs>
<Tab title="Mark as Unread">
<Tab title="Mark Messages as Unread">
```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);
Expand All @@ -478,12 +636,13 @@ CometChat.markAsUnread(message).then(
<Tab title="TypeScript">
```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);
}
);
```
Expand Down Expand Up @@ -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.

</Info>