/ SDKs / Android
SDKs
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4

Hide or archive a group channel

Copy link

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

KotlinKTX
// Hide or archive a group channel.
groupChannel.hide(hidePreviousMessages, allowAutoUnhide) { e ->
    if (e != null) {
        // Handle error.
    }

    // The channel is successfully hidden from the list.
    // The current user's channel view should be refreshed to reflect the change.
    // ...
}

// Unhide a group channel.
groupChannel.unhide { e ->
    if (e != null) {
        // Handle error.
    }

    // The channel is successfully unhidden from the list.
    // The current user's channel view should be refreshed to reflect the change.
}

List of parameters

Copy link
Parameter nameTypeDescription

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.

You can check the channel state on the channel list by using the hiddenState property of a GroupChannel object.

when (groupChannel.hiddenState) {
    HiddenState.UNHIDDEN -> {
        // Show the channel in the list.
    }
    HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE -> {
        // Hide the channel from the list, and get it appeared back on condition.
    }
    HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE -> {
        // Archive the channel, and get it appeared back in the list only when unhide() is called.
    }
}

You can also filter channels by their state by following the code below.

val query = GroupChannel.createMyGroupChannelListQuery(
    GroupChannelListQueryParams().apply {
        includeEmpty = true
        // The filter options are ALL, UNHIDDEN, HIDDEN, HIDDEN_ALLOW_AUTO_UNHIDE, and HIDDEN_PREVENT_AUTO_UNHIDE.
        // If set to HIDDEN, hidden and archived channels are returned.
        hiddenChannelFilter = HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE
    }
)
query.next { channels, e ->
        // Only archived channels are returned in a result list
        // through the channels parameter of the callback handler.
}