Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/pages/docs/chat/api/javascript/message-reactions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ The `subscribeRaw()` method takes the following parameters:
| name | Required | The reaction identifier. | String |
| count | Optional | The count for Multiple type reactions. | Number |
| clientId | Required | The client ID who sent the reaction. | String |
| userClaim | Optional | The user claim attached to this reaction by the server. Only present if the user's [JWT](/docs/auth/token#jwt) contained a claim for the room. | String or Undefined |

</Table>

Expand Down
1 change: 1 addition & 0 deletions src/pages/docs/chat/api/javascript/message.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The `Message` interface has the following properties:
| --- | --- | --- |
| serial | The unique identifier of the message. | String |
| clientId | The client ID of the user who created the message. | String |
| userClaim | The user claim attached to this message by the server. Only present if the publishing user's [JWT](/docs/auth/token#jwt) contained a claim for the room in which this message was published. | String or Undefined |
| text | The text content of the message. | String |
| timestamp | The timestamp at which the message was created. | Date |
| metadata | Extra information attached to the message for features like animations or linking to external resources. Always set; empty object if no metadata was provided. | <Table id='MessageMetadata'/> |
Expand Down
1 change: 1 addition & 0 deletions src/pages/docs/chat/api/javascript/presence.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ The `subscribe()` method takes the following parameters:
| Property | Description | Type |
| --- | --- | --- |
| clientId | The client ID of the present user. | String |
| userClaim | The user claim attached to this presence event by the server. Only present if the user's [JWT](/docs/auth/token#jwt) contained a claim for the room. | String or Undefined |
| connectionId | The connection ID of the present user. | String |
| data | The presence data associated with the user. | <Table id='PresenceData'/> or Undefined |
| extras | Additional data included with the presence message. | JsonObject or Undefined |
Expand Down
1 change: 1 addition & 0 deletions src/pages/docs/chat/api/javascript/room-reactions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ The `subscribe()` method takes the following parameters:
| --- | --- | --- |
| name | The name of the reaction (e.g., an emoji). | String |
| clientId | The client ID of the user who sent the reaction. | String |
| userClaim | The user claim attached to this reaction by the server. Only present if the user's [JWT](/docs/auth/token#jwt) contained a claim for the room. | String or Undefined |
| metadata | Additional metadata included with the reaction. Empty object if none provided. | JsonObject |
| headers | Additional information from Ably message extras. Empty object if none provided. | Headers |
| createdAt | When the reaction was sent. | Date |
Expand Down
24 changes: 17 additions & 7 deletions src/pages/docs/chat/api/javascript/typing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ The `Typing` interface has the following properties:

| Property | Description | Type |
| --- | --- | --- |
| current | The current set of client IDs who are typing in the room. | `Set<string>` |
| currentTypers | The set of users currently typing in the room, with associated metadata such as user claims. | <Table id='TypingMember'/> |

</Table>

<Table id='TypingMember' hidden>

| Property | Description | Type |
| --- | --- | --- |
| clientId | The client ID of the typing user. | String |
| userClaim | The user claim attached to this typing event by the server. Only present if the user's [JWT](/docs/auth/token#jwt) contained a claim for the room. | String or Undefined |

</Table>

Expand Down Expand Up @@ -81,7 +90,7 @@ The room must be [attached](/docs/chat/api/javascript/room#attach) to receive ty
<Code>
```javascript
const { unsubscribe } = room.typing.subscribe((event) => {
console.log('Currently typing:', Array.from(event.currentlyTyping));
console.log('Currently typing:', event.currentTypers.map(user => user.clientId));
});

// To stop receiving typing events
Expand All @@ -106,7 +115,7 @@ The `subscribe()` method takes the following parameters:
| Property | Description | Type |
| --- | --- | --- |
| type | The type of the event. Always `SetChanged`. | <Table id='TypingSetEventType'/> |
| currentlyTyping | Set of client IDs currently typing in the room. | `Set<string>` |
| currentTypers | The set of users currently typing, with associated metadata such as user claims. | <Table id='TypingMember'/> |
| change | Information about the specific change that triggered this event. | <Table id='TypingChange'/> |

</Table>
Expand All @@ -125,6 +134,7 @@ The `subscribe()` method takes the following parameters:
| --- | --- | --- |
| clientId | The client ID whose typing state changed. | String |
| type | Whether the user started or stopped typing. | <Table id='TypingEventType'/> |
| userClaim | The user claim attached to this typing event by the server. Only present if the user's [JWT](/docs/auth/token#jwt) contained a claim for the room. | String or Undefined |

</Table>

Expand Down Expand Up @@ -163,14 +173,14 @@ await room.attach();

// Subscribe to typing events
const { unsubscribe } = room.typing.subscribe((event) => {
const typingUsers = Array.from(event.currentlyTyping);
const typingUsers = event.currentTypers;

if (typingUsers.length === 0) {
console.log('No one is typing');
} else if (typingUsers.length === 1) {
console.log(`${typingUsers[0]} is typing...`);
console.log(`${typingUsers[0].clientId} is typing...`);
} else {
console.log(`${typingUsers.join(', ')} are typing...`);
console.log(`${typingUsers.map(user => user.clientId).join(', ')} are typing...`);
}
});

Expand All @@ -190,7 +200,7 @@ inputField.addEventListener('blur', async () => {
});

// Check who is currently typing
console.log('Currently typing:', room.typing.current);
console.log('Currently typing:', room.typing.currentTypers);

// Clean up
unsubscribe();
Expand Down