Skip to content

v4.3.0

Choose a tag to compare

@raj-dubey1 raj-dubey1 released this 02 Nov 12:45
· 1 commit to v4 since this release
d061ae5

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/main and installCometChatBridge() from @cometchat/chat-sdk-javascript/electron/preload. Electron 20 or later and better-sqlite3-multiple-ciphers 9 or later are required as optional peer dependencies.

  • Introduced OfflineConfig to configure cache size and lifetime, pending-message limits, queue overflow policies, automatic message delivery after reconnection, media caching, and encryption.

  • Added optional MessageSentListener support to sendMessage(), sendMediaMessage(), sendCustomMessage(), and sendInteractiveMessage(). When offline support is enabled, messages sent with a listener are queued and delivered when connectivity returns. Added getPendingMessages(), retryMessage(), retryAllFailedMessages(), and discardLocalMessage() to manage pending messages, along with addOfflineMessageListener() to monitor queue updates.

  • Added optional listener support to fetchNext(), fetchPrevious(), getMessageDetails(), and getConversation(). Listeners such as MessageFetchListener and ConversationDetailsListener receive cached results first, followed by updated results from the server.

  • Added getSyncState(), forceSyncNow(), and addSyncListener() to monitor and control synchronization. Introduced getCacheSize() and clearOfflineCache() for cache management, along with downloadMedia(), getCachedMediaObjectURL(), and addMediaDownloadListener() 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. Added getOfflineEncryptionStatus() 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(), and getUpdatedAt() to messages, along with getLocalPath() 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 returned ERROR_SET_LIMIT_EXCEEDED.

  • Enhanced UploadFileRequest with getFiles() and getItems() to retrieve all files in a batch, including their individual upload states. Updated retryAttachment() to accept an optional listener. With offline support enabled, CometChat.getExistingUploadFileRequest() restores upload batches after an application reload, and getFileBytes() 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 returns null when no attachments are available.

  • Fixed inconsistent conversationWith values in onConversationPinned and onConversationUnpinned events triggered by actions on another device. The property now contains a User or Group object 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. Use setAttachments([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, including getConversation(). Update typed wrappers that rely on Parameters<> to declare their parameter types explicitly.

  • Increased the minified CometChat.js bundle 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) invokes onMessagePending, followed by onError with FAILED_TO_FETCH, and rejects the returned Promise while keeping the message queued. Do not resend the message when this error occurs. The SDK invokes onMessageSent when connectivity returns, while onOutboxMessageFailed reports 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() and addOfflineMessageListener() immediately after await 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.