Skip to content

Commit

Permalink
fix message receipts getting disabled if custom throttleTime is passed (
Browse files Browse the repository at this point in the history
  • Loading branch information
mhiaror authored Oct 2, 2024
1 parent eec7572 commit 9d33ec5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/core/chatSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ var setGlobalConfig = config => {
GlobalConfig.updateThrottleTime(config.features?.messageReceipts?.throttleTime);
if (config.features?.messageReceipts?.shouldSendMessageReceipts === false) {
GlobalConfig.removeFeatureFlag(FEATURES.MESSAGE_RECEIPTS_ENABLED);
} else {
/**
* Note: if update config is called with `config.features` array, it replaces default config
* this ensure `message-receipts` feature is always enabled.
* Only way to disable message receipts is by setting config.features.messageReceipts.shouldSendMessageReceipts == false
* */
setFeatureFlag(FEATURES.MESSAGE_RECEIPTS_ENABLED);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/globalConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class GlobalConfigImpl {
this.endpointOverride = config.endpoint || this.endpointOverride;
this.reconnect = config.reconnect === false ? false : this.reconnect;
this.messageReceiptThrottleTime = config.throttleTime ? config.throttleTime : 5000;
const features = config.features || this.features.values;
// update features only if features is of type array.
const features = Array.isArray(config.features) ? config.features : this.features.values;
this.features["values"] = Array.isArray(features) ? [...features] : new Array();
}

Expand Down

0 comments on commit 9d33ec5

Please sign in to comment.