/ SDKs / JavaScript
SDKs
Chat SDKs JavaScript v4
Chat SDKs JavaScript
Chat SDKs
JavaScript
Version 4

Hide or archive a group channel

Copy link

You can use the following code to hide or archive a specific group channel from the channel list UI.

JavaScriptTypeScript
// Hide or archive a group channel.
const params = {
    hidePreviousMessages: false,
    allowAutoUnhide: true,
};
await channel.hide(params);

// Unhide a group channel.
await channel.unhide();

GroupChannelHideParams

Copy link
ArgumentTypeDescription

hidePreviousMessages

boolean

Determines whether to show the messages sent and received before hiding or archiving the channel on the channel list. If set to true, previous messages aren't displayed in the channel. (Default: false)

allowAutoUnhide

boolean

Determines the state and operating behavior of a channel. If set to true, the channel is hidden from the channel list, but when a new message arrives, the hidden channel will show up again on the channel list. If set to false, the channel is archived and stays hidden from the channel list unless the unhide() method is called. (Default: true)

By using the channel.hiddenState property, you can check the channel state on the channel list.

JavaScriptTypeScript
if (channel.hiddenState === HiddenState.UNHIDDEN) {
    // Display the channel in the list.
} else if (channel.hiddenState === HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE) {
    // Hide the channel from the list and show again depending on the set value.
} else if (channel.hiddenState === HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE) {
    // Archive the channel and show again on the list only when the unhide() method is called.
}

You can also filter channels by their state like the following.

JavaScriptTypeScript
const params = {
    includeEmpty: true,
    hiddenChannelFilter: HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE,
    // ...
};
const query = sb.groupChannel.createMyGroupChannelListQuery(params);