Repository navigation
v4.3.0
New
-
Added optional offline support, disabled by default. Enable it using
new CometChat.AppSettingsBuilder().setOfflineConfig({ enabled: true })or.offline(true)to use the default configuration. The SDK maintains an on-device cache for each app and user, serves cached results first, queues eligible outgoing messages, and synchronizes data when connectivity is restored. -
Added offline support for browser and Electron applications. Browser environments use IndexedDB for data storage and OPFS for media, requiring no additional setup. Electron applications use SQLite in the main process and require
registerOfflineIpc()from@cometchat/chat-sdk-javascript/electron/mainandinstallCometChatBridge()from@cometchat/chat-sdk-javascript/electron/preload. Electron 20 or later andbetter-sqlite3-multiple-ciphers9 or later are required as optional peer dependencies. -
Introduced
OfflineConfigto configure cache size and lifetime, pending-message limits, queue overflow policies, automatic message delivery after reconnection, media caching, and encryption. -
Added optional
MessageSentListenersupport tosendMessage(),sendMediaMessage(),sendCustomMessage(), andsendInteractiveMessage(). When offline support is enabled, messages sent with a listener are queued and delivered when connectivity returns. AddedgetPendingMessages(),retryMessage(),retryAllFailedMessages(), anddiscardLocalMessage()to manage pending messages, along withaddOfflineMessageListener()to monitor queue updates. -
Added optional listener support to
fetchNext(),fetchPrevious(),getMessageDetails(), andgetConversation(). Listeners such asMessageFetchListenerandConversationDetailsListenerreceive cached results first, followed by updated results from the server. -
Added
getSyncState(),forceSyncNow(), andaddSyncListener()to monitor and control synchronization. IntroducedgetCacheSize()andclearOfflineCache()for cache management, along withdownloadMedia(),getCachedMediaObjectURL(), andaddMediaDownloadListener()for media management. -
Added optional encryption at rest through
encryption: true. Browser environments use AES-256-GCM to encrypt stored message and list content, while Electron uses SQLCipher to encrypt the entire database. Cached media files are not encrypted, and certain lookup fields, including IDs and timestamps, remain readable in browsers. AddedgetOfflineEncryptionStatus()to report the active encryption status. -
Introduced
addOfflineCacheResetListener()to notify applications when the offline cache is rebuilt and report the number of unsent messages lost during the reset. -
Added
getLocalMessageId(),getSource(), andgetUpdatedAt()to messages, along withgetLocalPath()to attachments.
Enhancements
-
Increased the maximum supported limit in
ReactionsRequestBuilder.setLimit()to 1000. Values exceeding 1000 are automatically capped at 1000. Previously, limits greater than 20 returnedERROR_SET_LIMIT_EXCEEDED. -
Enhanced
UploadFileRequestwithgetFiles()andgetItems()to retrieve all files in a batch, including their individual upload states. UpdatedretryAttachment()to accept an optional listener. With offline support enabled,CometChat.getExistingUploadFileRequest()restores upload batches after an application reload, andgetFileBytes()retrieves a file's locally stored copy.
Fixes
-
Fixed an issue where
MediaMessage.getAttachment()threw an error when called on a message without attachments. The method now returnsnullwhen no attachments are available. -
Fixed inconsistent
conversationWithvalues inonConversationPinnedandonConversationUnpinnedevents triggered by actions on another device. The property now contains aUserorGroupobject with its ID. Fetch the conversation to retrieve its complete details. -
Fixed an issue where
UploadFileRequest.removeUploadListener()removed listeners belonging to the entire upload batch, including listeners registered through other requests. The method now removes only the listener registered through the specific request.
Breaking Changes
-
Changed
MediaMessage.setAttachment()to append attachments instead of replacing existing ones, regardless of whether offline support is enabled. Calling the method multiple times now includes all added attachments in the outgoing message. UsesetAttachments([attachment])when replacing existing attachments is required. -
Changed
MediaMessage.getAttachments()to return the same array instance on every call. Additionally,getAttachment()now consistently returns the first attachment. Copy the returned array before modifying or sorting it, for example,[...message.getAttachments()].reverse(). -
Changed TypeScript overload resolution for methods that now accept optional listeners.
Parameters<typeof CometChat.sendMessage>now resolves to the overload requiring a listener. The same behavior applies to other methods with new listener overloads, includinggetConversation(). Update typed wrappers that rely onParameters<>to declare their parameter types explicitly. -
Increased the minified
CometChat.jsbundle size from approximately 603 KB to 1,136 KB and the gzipped size from approximately 109 KB to 229 KB. This increase applies regardless of whether offline support is enabled. Review bundle-size budgets before upgrading. -
Changed message delivery behavior when offline support is enabled and no connection is available. Calling
sendMessage(message, listener)invokesonMessagePending, followed byonErrorwithFAILED_TO_FETCH, and rejects the returned Promise while keeping the message queued. Do not resend the message when this error occurs. The SDK invokesonMessageSentwhen connectivity returns, whileonOutboxMessageFailedreports messages that ultimately fail. Messages sent without a listener are not queued and continue to reject as before. -
Introduced at-least-once delivery for queued messages. Duplicate messages may appear in a conversation if the server accepts a request after the SDK stops waiting for its response or if the application restarts during delivery.
-
Required applications using offline support to register
addOfflineCacheResetListener()andaddOfflineMessageListener()immediately afterawait CometChat.init(), before awaiting other operations. This ensures that startup notifications are received. -
Changed Electron offline bridge security behavior to accept calls from any top-level frame, regardless of origin. Applications that load external content must configure
registerOfflineIpc({ isTrustedSender })to restrict trusted senders. -
Changed Electron offline storage to maintain data for only one app and user at a time. Signing in as a different user deletes the previously stored user's local data.