Pin a channel
Pin channels to the top of the channel list for quick access.
Pin a channel
TypeScript
import { DirectChannel } from '@nexconn/chat';
const channel = new DirectChannel('<target-user-id>');
const { code } = await channel.pin();
if (code === 0) {
console.log('Channel pinned');
}
Unpin a channel
TypeScript
import { DirectChannel } from '@nexconn/chat';
const channel = new DirectChannel('<target-user-id>');
const { code } = await channel.unpin();
if (code === 0) {
console.log('Channel unpinned');
}
Listen for pin status changes
When a channel is pinned or unpinned on another device, the ChannelHandler callback fires to keep all clients in sync:
TypeScript
import { NCEngine, ChannelHandler } from '@nexconn/chat';
NCEngine.addChannelHandler('pin-handler', new ChannelHandler({
onChannelPinnedSync({ channelIdentifier, isPinned }) {
console.log('Channel pin status changed:', channelIdentifier, 'pinned:', isPinned);
},
}));
tip
You can retrieve all pinned channels by calling BaseChannel.getPinnedChannels(channelTypes).
TypeScript
import { BaseChannel, ChannelType } from '@nexconn/chat';
const { code, data } = await BaseChannel.getPinnedChannels([
ChannelType.Private,
ChannelType.Group,
]);
if (code === 0) {
console.log('Pinned channels:', data);
}