Deleting & Hiding a Channel

Last Edit: Mar 03 2020

You can delete a Channel using the delete method. This marks the channel as deleted and hides all the content.


const destroy = await channel.delete();
                    

$channel->delete();
                    

await channel.delete();
                    

channelController.delete().enqueue {
    val channel = it.data()
}
                    
If you recreate this channel, it will show up empty. Recovering old messages is not currently supported via the Stream Chat API.

Hiding a Channel

Hiding a channel will remove it from query channel requests for that user until a new message is added. Please keep in mind that hiding a channel is only available to members of that channel.

Optionally you can also clear the entire message history of that channel for the user. This way, when a new message is received, it will be the only one present in the channel.


// hides the channel until a new message is added there
await channel.hide();

// shows a previously hidden channel
await channel.show();
                    

// hides the channel until a new message is added there
$channel->hide('elon');

// shows a previously hidden channel
$channel->show('elon');
                    

// hides the channel until a new message is added there
await channel.hide();

// shows a previously hidden channel
await channel.show();

// hide the channel and clear the message history
await channel.hide(clearHistory: true);
                    

// hides the channel until a new message is added there
channelController.hide().enqueue {
    val channel = it.data()
}

// shows a previously hidden channel
channelController.show().enqueue {
    val channel = it.data()
}

// hide the channel and clear the message history
channelController.hide(true).enqueue {
    val channel = it.data()
}
                    
You can still retrieve the list of hidden channels using the { "hidden" : true } query parameter.