Skip to content

Commit

Permalink
chat-core: decreased timeout of the stop typing timer
Browse files Browse the repository at this point in the history
- 10 seconds seemed a bit excessive after testing, and I think it may confuse developers who incorrectly assume they have to manual call stop() after seeing that the timer doesn't expire after a few seconds.
- Reduce timeout to 5 seconds.
- Updated the readme in react for clarity.
  • Loading branch information
splindsay-92 committed Oct 18, 2024
1 parent 5c2da95 commit 90888b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/room-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const RoomOptionsDefaults = {
/**
* The default timeout for typing events in milliseconds.
*/
timeoutMs: 10000,
timeoutMs: 5000,
} as TypingOptions,

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ export interface TypingOptions {
/**
* The timeout for typing events in milliseconds. If typing.start() is not called for this amount of time, a stop
* typing event will be fired, resulting in the user being removed from the currently typing set.
* @defaultValue 10000
* @defaultValue 5000
*/
timeoutMs: number;
}
Expand Down
4 changes: 4 additions & 0 deletions src/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ nearest `ChatRoomProvider`.
You can also be supply an optional listener that will receive the underlying typing events,
or use the state object returned by the hook to access the current list of clients currently typing.

**The default timeout on the typing indicator can be configured in the `options` parameter you provided
to the `ChatRoomProvider`.**

```tsx
import { useTyping } from '@ably/chat/react';

Expand All @@ -351,6 +354,7 @@ const MyComponent = () => {
});

const handleStartClick = () => {
// calling starts a timer that will automatically call stop() after a pre defined time
start();
};

Expand Down

0 comments on commit 90888b1

Please sign in to comment.