Skip to content

feat: use countdown timer from channel in client JS#3381

Merged
khushal87 merged 5 commits intodevelopfrom
feat/use-cooldown-timer-from-llc
Feb 4, 2026
Merged

feat: use countdown timer from channel in client JS#3381
khushal87 merged 5 commits intodevelopfrom
feat/use-cooldown-timer-from-llc

Conversation

@khushal87
Copy link
Member

@khushal87 khushal87 commented Feb 3, 2026

This pull request refactors how cooldown logic is handled in the message input components. The main improvement is centralizing cooldown state management using new hooks, which simplifies component props and reduces duplicated logic by using the Cooldown state from Channel in LLC.

Cooldown logic refactor:

  • Removed the old useCooldown hook and its associated prop threading, consolidating cooldown state management. (package/src/components/MessageInput/hooks/useCooldown.ts [1] package/src/components/MessageInput/MessageInput.tsx [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
  • Introduced a new useCooldownRemaining hook to provide the current cooldown state from the channel context, and updated all relevant components to use this hook. (package/src/components/MessageInput/hooks/useCooldownRemaining.tsx [1] package/src/components/AutoCompleteInput/AutoCompleteInput.tsx [2] [3]
  • Updated CooldownTimer to use the new hook and improved its styling to use theme primitives, ensuring consistent appearance. (package/src/components/MessageInput/components/OutputButtons/CooldownTimer.tsx [1] [2] [3]

Output button logic improvements:

  • Refactored OutputButtons to use a new useIsCooldownActive hook and simplified the rendering logic for send, edit, and cooldown buttons, making use of useMemo for performance and clarity. (package/src/components/MessageInput/components/OutputButtons/index.tsx [1] [2] [3] [4] [5] [6] [7]

These changes make the codebase easier to maintain and extend, and ensure that cooldown logic is handled consistently across components.

@Stream-SDK-Bot
Copy link
Contributor

Stream-SDK-Bot commented Feb 3, 2026

SDK Size

title develop branch diff status
js_bundle_size 355 KB 355 KB 0 B 🟢

@khushal87 khushal87 requested a review from isekovanic February 3, 2026 06:57
export const CooldownTimer = (props: CooldownTimerProps) => {
const { seconds } = props;
export const CooldownTimer = () => {
const seconds = useCooldownRemaining();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we display seconds on both the CooldownTimer as well as the AutoCompleteInput ? Is this by design ?

Asking because otherwise we can simply check if the cooldown is happening in the input otherwise, rather than rerendering every time there's a tick.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is by design

@khushal87 khushal87 merged commit a4610cc into develop Feb 4, 2026
5 checks passed
@khushal87 khushal87 deleted the feat/use-cooldown-timer-from-llc branch February 4, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants