Sync read status across devices
Synchronize read status for community subchannels across multiple devices.
How it works
When a user reads messages in a community subchannel on one device, the read timestamp syncs to other devices. This prevents stale unread badges on the user's other sessions.
Clear unread count (triggers sync)
TypeScript
import { CommunitySubChannel } from '@nexconn/chat';
const channel = new CommunitySubChannel('<communityId>', '<subChannelId>');
const { code } = await channel.clearUnreadCount();
if (code === 0) {
console.log('Read status synced');
}
Listen for read status sync events
Register a ChannelHandler to receive community channel status sync completion:
TypeScript
import { NCEngine, ChannelHandler } from '@nexconn/chat';
NCEngine.addChannelHandler('read-sync-handler', new ChannelHandler({
onCommunityChannelsSyncCompleted() {
// Called when community channel status (including read status) finishes syncing
console.log('Community channels sync completed');
},
onChannelStatusSyncCompleted({ code }) {
// Called when general channel status data sync completes
console.log('Channel status sync completed. Code:', code);
},
}));