Skip to content

Commit

Permalink
do not send typing if indicators are disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kanat committed Apr 30, 2024
1 parent ee9cd48 commit f3b5581
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,9 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
if (!this.getConfig()?.typing_events) {
return;
}
if (!this._isTypingIndicatorsEnabled()) {
return;
}
const now = new Date();
const diff = this.lastTypingEvent && now.getTime() - this.lastTypingEvent.getTime();
this.lastKeyStroke = now;
Expand All @@ -683,6 +686,9 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
if (!this.getConfig()?.typing_events) {
return;
}
if (!this._isTypingIndicatorsEnabled()) {
return;
}
this.lastTypingEvent = null;
this.isTyping = false;
await this.sendEvent({
Expand All @@ -692,6 +698,10 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
} as Event<StreamChatGenerics>);
}

_isTypingIndicatorsEnabled(): boolean {
return this.getClient().user?.privacy_settings?.typing_indicators?.enabled ?? true;
}

/**
* lastMessage - return the last message, takes into account that last few messages might not be perfectly sorted
*
Expand Down

0 comments on commit f3b5581

Please sign in to comment.