You can view any public channel even if you are not a member.
The list is paginated, so to get to the next page, you can pass the ID of the last of the channel objects returned by the previous lookup to get to the next page.
You can set hasUnread to "true" to see only channels where you have an unread message.
The list is paginated, so to get to the next page, you can pass the ID of the last of the channel objects returned by the previous lookup to get to the next page.
const numOfRows = 20;
const resp = await client.getChannels({
limit: numOfRows,
category: 'important_channels', // optional
subcategory: 'important_subcategory', // optional
isFrozen: false, // optional. filter by isFrozen status
hasUnread: true, // optional. only true is supported. when true, shows only unread channels.
privateTag: 'tag1', // optional. see: https://en.docs.talkplus.io/javascript/channel/member-settings
});
if (resp.hasNext) {
const lastChannelId = resp.channels[resp.channels.length - 1].id;
const moreChannelsResp = await client.getChannels({lastChannelId, limit: numOfRows});
}
// same query but using callback
client.getChannels({}, function(err, resp) {
if (resp.hasNext) {
const lastChannelId = resp.channels[resp.channels.length - 1].id;
}
});
3. Get Hidden Channels
View currently joined channels that have been marked as hidden.
The list is paginated, so to get to the next page, you can pass the ID of the last of the channel objects returned by the previous lookup to get to the next page.
const numOfRows = 20;
const resp = await client.getHiddenChannels({limit: numOfRows});
if (resp.hasNext) {
const lastChannelId = resp.channels[resp.channels.length - 1].id;
const moreChannelsResp = await client.getHiddenChannels({lastChannelId, limit: numOfRows});
}
// same query but using callback
client.getHiddenChannels({}, function(err, resp) {
if (resp.hasNext) {
const lastChannelId = resp.channels[resp.channels.length - 1].id;
}
});
Get the total number of unread messages from all joined channels.
// get total unread count
const resp = await client.getUnreadCount();
console.log('unreadCount: ', resp.count);
// filter unread message count by channel category, subcategory and privateTag.
// this feature is available starting from v0.5.6.
const filteredResp = await client.getUnreadCount({
category: 'someCategory', // optional
subcategory: 'someSubcategory', // optional
privateTag: 'some personal tag', // optional
});
console.log('filtered unreadCount: ', filteredResp.count);
5. Mark All Channels As Read
Mark as read all unread messages from joined channels.
await client.markAsReadAllChannel();
6. Search Joined Channels
Search joined channels using various filters.
You can filter channels by name, category, subcategory, private tag and joined members. You can set hasUnread to "true" to see only channels where you have an unread message.
The list is paginated, so to get to the next page, you can pass the ID of the last of the channel objects returned by the previous lookup to get to the next page.
const resp = await client.searchChannels({
query: 'some channel name',
members: ['someUserId1', 'someUserId2'], // filter by joined members
category: 'someCategory', // optional
subcategory: 'someCategory', // optional
privateTag: 'myTag',
isFrozen: false, // optional. filter by isFrozen status
hasUnread: true, // optional. only true is supported. when true, shows only unread channels.
lastChannelId: 'someChannelID',
limit: 10,
});
if (resp.hasNext) {
// retrieve next page
}